finding newest id
Posted: Sun Dec 16, 2007 8:03 pm
ok, i have a code for a news system, and what im trying to do is echo New by the newest post, so the new news is marked new. ive tried using a query for max(id), but it will only show the newest news and thats it. i need it to still show all the others as well. this is the code im using right now.
ive tried just about everything i can think of. the code in there right now puts NEW by every single news item. please help me 
(the rest of the code simply prints the titles and dates of the news, and i didnt see a reason to post it, but that is why the code is still open)
Code: Select all
$query = "SELECT id, title, timestamp, type FROM news ORDER BY timestamp DESC LIMIT 0, 7";
$result = mysql_query($query) or die ("Error in query: $query . " . mysql_error());
// if records present
if (mysql_num_rows($result) > 0)
{
//iterate through resultset
// print article titles
while($row = mysql_fetch_object($result))
{
?>
</p>
<?php
$type = $row->type;
$id = $row->id;
$title = $row->title;
$timestamp = formatDate($row->timestamp);
if (($id+1) != $row->id){
echo "NEW! ";
}(the rest of the code simply prints the titles and dates of the news, and i didnt see a reason to post it, but that is why the code is still open)