Jump to content

Archived

This topic is now archived and is closed to further replies.

Gruzin

Last row from db

Recommended Posts

Hi guys,
I have a very simple question: how can I echo the last row from db?

Thanks for your time,
George

Share this post


Link to post
Share on other sites
if you have an auto-incrementing id field, you can simply sort by that field:
[code]
<?php
$sql = mysql_query("SELECT * FROM table ORDER BY id DESC LIMIT 1");
$row = mysql_fetch_row($sql);
foreach ($row as $key => $val) echo "$key => $val<br />\n";
?>
[/code]

hope this helps

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.