fesan Posted March 23, 2007 Share Posted March 23, 2007 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. Quote Link to comment Share on other sites More sharing options...
Hell Toupee Posted March 23, 2007 Share Posted March 23, 2007 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. Quote Link to comment Share on other sites More sharing options...
fesan Posted March 23, 2007 Author Share Posted March 23, 2007 Thanks.... Yes there is a auto_increment field.... This worked perfektly! Thank you again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.