Jump to content

Latest SQL data...


fesan

Recommended Posts

Hi....

 

Is there a way to get the last row of a table and get the data out of just that row?

With PHP and MySQL....

 

I've tryed a simple way but it seams quite unstable:

 

$finn_refnr = "SELECT refnr FROM ${db_records}"; 
$result_refnr = mysql_query($finn_refnr) or die(mysql_error());
while($row = mysql_fetch_array($result_refnr)){
$new_refnr = $row['refnr'];
echo $new_refnr;
}

 

Sorry for my norwegianenglish and the norwegian typing in the script.

Link to comment
Share on other sites

Order it by date or by a cumulative unique identifier, do you have any auto_increment fields?

 

$finn_refnr = "SELECT refnr FROM $db_records ORDER by "auto_increment field here" DESC LIMIT 0,1  ";

 

That will order the query by the most recent, and limit the number of results to 1. To give you the exact query i'd need to know what fields are in your database and what they do.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.