Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Reset ID(int) to last + 1? Re: Reset ID(int) to last + 1?

#96011
bungle
Member

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