php date
Posted: Thu May 22, 2003 9:47 am
have a table called anime
It has e.g. Anime_id, Anime_name, Date_add
When a anime title is added to my database, php stores the date that it was added.
I am trying to then display what has been added in, lets say within 30 days
My code
Code:
Now, if i run the sql command
in mysql, it gives me results
but if i use the php code, i get no results
Can anyone help
It has e.g. Anime_id, Anime_name, Date_add
When a anime title is added to my database, php stores the date that it was added.
I am trying to then display what has been added in, lets say within 30 days
My code
Code:
Code: Select all
<?php
$db =mysql_connect("localhost","jam", "");
mysql_select_db("ja",$db);
$sql = "SELECT * FROM anime
WHERE TO_DAYS(NOW()) - TO_DAYS(Date_add) <= 30 ";
$rs=mysql_query($sql,$db);
$numofrows =mysql_num_rows($rs);
for ($x = 0; $x <$numofrows; $x++)
{
$row = mysql_fetch_array($rs);
?>
<td bgcolor="#FFFFCC"><font size="-1"><?php echo $row['Anime_name']; ?></td>
<?php
}
?>Now, if i run the sql command
Code: Select all
<?php
SELECT * FROM anime
WHERE TO_DAYS(NOW()) - TO_DAYS(Date_add) <= 30 ;
?>in mysql, it gives me results
but if i use the php code, i get no results
Can anyone help