I need to insert a 6 digit key into my database. I can't figure out how to do the loop part. If the key is in use I need to keep generating a new key and checking it to make sure its not in use.
$row=mysql_fetch_assoc(mysql_query("SELECT count(*) as numrecords FROM id WHERE id='".$generated_id."'");
if ($row['numrecords'] >= 1)
{
//key is in use generate new key and loop to make sure its not in use
}
else
{
//insert key
}
mysql_close();
Thanks