I need help in the following query in php. I want to create auto number like 0001, 0002. I am using this query
$query = "SELECT MAX(cast(registration_code as decimal)) id FROM accounts ";
if($result = mysql_query($query))
{
$row = mysql_fetch_assoc($result);
$count = $row['id'];
$count = $count+1;
$code_no = str_pad($count, 4, "0", STR_PAD_LEFT);
}
It is working right but the problems is that when i delete any number like 0001, 0002, 0003 and i delete 0002 this create 0004 i want this will create deleted number i mean 0001 to 0003 if missing any that creat
thanks