MySQL Forums
Forum List  »  PHP

Reset auto_increment after deleting
Posted by: Emiliano Ruggeri
Date: August 03, 2005 01:25AM

Auto_increment does not fill in blank spaces it just adds "one" to the highest number. Is there a better way to reset the values then this:


$new_number = "1";
$result = @mysql_query ('SELECT * FROM test_table ORDER BY user_id');
while ($resets = @mysql_fetch_array($result))
{
$new_id = $resets['user_id'];
$update = @mysql_query("UPDATE test_table SET
user_id ='$new_number' WHERE
user_id ='$new_id';");
$new_number = ($new_number + 1);

}


Thanks
Emiliano

Options: ReplyQuote


Subject
Written By
Posted
Reset auto_increment after deleting
August 03, 2005 01:25AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.