I am trying to display records from last one min onward using the following query:
But unfortunetly it doesn't display those data within one min. It displays all the data!!
The date is stored like this 2007-04-17 11:44:35 in my mysql table. could any one look at the query that i use
and let me know what i am doing wrong?Thanks
date feild datatype:`date` datetime NOT NULL default '0000-00-00 00:00:00',
query used to insert data using Now():
$query = "INSERT INTO album (`ID`, `date`) VALUES ('$ID',NOW() )";
Date stored format:2007-04-17 11:44:35
Code:
res = mysql_query('SELECT * FROM album where date > "$timeout"') or die('<error>'.mysql_error().'</error>');
But unfortunetly it doesn't display those data within one min. It displays all the data!!
The date is stored like this 2007-04-17 11:44:35 in my mysql table. could any one look at the query that i use
and let me know what i am doing wrong?Thanks
date feild datatype:`date` datetime NOT NULL default '0000-00-00 00:00:00',
query used to insert data using Now():
$query = "INSERT INTO album (`ID`, `date`) VALUES ('$ID',NOW() )";
Date stored format:2007-04-17 11:44:35
Code:
<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
$server = "localhost"; // MySQL hostname
$username = "root"; // MySQL username
$password = "root"; // MySQL password
$dbname = "db"; // MySQL db name
$db = mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
// this is necessary, otherwise it won't work:
header('Content-type: application/xml');
// you need to return the error as xml as well
$timeout = time() - 60; // number of seconds to keep users in database
$res = mysql_query('SELECT * FROM album where date > "$timeout"') or die('<error>'.mysql_error().'</error>');
// display the root node of the xml, and start looping over the elements:
echo '<playlist>';
while($row = mysql_fetch_assoc($res)){
echo '<song>';
echo '<artist>'.$row['albumname'].'</artist>';
echo '</song>';
}
echo '</playlist>';
?>