i have 2 tables for categories & posts
the categories table contain
id
name
and the posts table contain
id
name
post
added_date
the date stored like (2010-09-05).
when i print the categories by this code
$query=mysql_query("select id,name from categories order by id");
while($row=mysql_fetch_assoc($query)){
echo "$row[id] : $row[name] <br />";
}
i need to print word ( new ) next to the category that have any new post for 3 days only after three days it should be normal category name without word (NEW).
regards
You need to change your query to report the newest posting date for each category. The simplest way to do this is with an aggregate function in the query:
Then, when printing the list of categories, if the value of the last_date column is newer than 4 days old, print the (new) text. For example: