Php - Move to the last record in the database

How do i directly move on to the last record using Php and mysql
Who is Participating?
jayyConnect With a Mentor Commented:
Hi karanp,

Here's some code that I think might solve.

$result = mysql_query($query);

// Get the number of result returned
$i = mysql_num_rows($result) - 1;

// This should seek to the last record in your database

mysql_data_seek($result, $i);

$row = mysql_fetch_row($result);

Good luck

F PCommented:
"ORDER BY id DESC" in your query won't work?
F PCommented:
... or "SELECT MAX(id) FROM database;" format of your SQL?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.