i currently have a script which creates new entries in a mysql database with a random ID number in the first field - generated from a rand() command. is there an easy way to check for a duplicate ID number before inserting each new entry?
BoB.
In PHP:
$result=mysql_query('select id from mytable'); $ids=array(); while($id=mysql_fetch_row($result)) $ids[]=$id[0]; do {...generate a random $id }while(in_array($id,$ids);
$id is your unique random id.