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);
Personally, I prefer to tackle this at the ERD end of things,
incorporating a "created" datetime field in the table.