faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

How to check if a newer entry id in mysql db? If yes, use 1 field in latest record as a variable.

Mar 19th, 2008 22:36
ha mo, Adam Jenkins, Preeti Birla,


This depends on whether or not you employ sequential IDs. If not, you
could base "Newer" on "the last" record in the table, but I certainly
wouldn't rely on this. If the IDs are sequential, perhaps you could try:
$results = mysql_query("select max(ID) from table");
if ($results && mysql_num_rows($results) == 1)
{
  $row = mysql_fetch_array($results);
  etc.
}
Personally, I prefer to tackle this at the ERD end of things,
incorporating a "created" datetime field in the table.
http://www.tantofa.com
http://www.fantofa.com
http://www.mantofa.com
http://www.tanpola.com
http://www.tampola.com
http://www.yamot.com
http://www.mozmar.com
http://www.templatestemp.com