Let\'s say I have the following data in the Customers table: (nothing more)
ID FirstName LastName ------------------------------- 20 John Macken
In PHP:
$sql = mysql_query("select id from customers order by id desc"); $rs = mysql_fetch_array($sql); if ( !$rs ) { $newid = 1; } else { $newid = $rs[newid]+1; }
thus $newid = 23 if last record in column id was 22.
$newid = 23