Page 1 of 1

displayin the last updated record

Posted: Thu Mar 03, 2005 5:55 pm
by nhan
sirs, i hope you wont get annoyed with some of my questions....

how can i display the last updated record in my table...
or maybe the last maximux record with that user...

heres my code:

$query = "select * from tbl where userName = '$user' and timeid >= (LAST_INSERT_ID())";
$result = mysql_query($query);

while($nt=mysql_fetch_array($result)){
echo "<html><body><span class='style7'>data1 :</span> $nt[userName] <span class='style7'>data2: </span>$nt[data2] <span class='style7'>data3: </span>$nt[data3]<span class='style7'> data4 : </span>$nt[data4]<br>\n</body></html>";

}


the output of this code is that it displays all the record entry of that user...
how can i make it to display the last entry.... maybe some revising of the code will do....


thanks so much!

-- sernan

Posted: Thu Mar 03, 2005 5:58 pm
by feyd

Code: Select all

SELECT * FROM `tbl` WHERE `userName` = '$user' ORDER BY `timeid` DESC LIMIT 1

displayin the last updated record

Posted: Thu Mar 03, 2005 6:05 pm
by nhan
feyd,

sir thanks so much! i really appreciated ur help! it worked!

regards,

nhan