displayin the last updated record

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
nhan
Forum Commoner
Posts: 95
Joined: Sun Feb 27, 2005 8:26 pm
Contact:

displayin the last updated record

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

SELECT * FROM `tbl` WHERE `userName` = '$user' ORDER BY `timeid` DESC LIMIT 1
User avatar
nhan
Forum Commoner
Posts: 95
Joined: Sun Feb 27, 2005 8:26 pm
Contact:

displayin the last updated record

Post by nhan »

feyd,

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

regards,

nhan
Post Reply