Home › Forums › Back End › Reset ID(int) to last + 1? › Re: Reset ID(int) to last + 1?
February 2, 2012 at 1:49 pm #96011
Something like this (untested and off the top of my head)….
after deleting A you would need to run the following before inserting B
$sql=’SELECT MAX(id) AS max FROM imgtable’;
$query = mysql_query($sql);
$result = mysql_fetch_array($query);
$resetcount = $result+1;
$sql = ‘ALTER TABLE imgtable AUTO_INCREMENT=’.$resetcount;
That would set the auto id to the highest value in the table + 1