• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

Php - Move to the last record in the database

How do i directly move on to the last record using Php and mysql
  • 2
1 Solution
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.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now