Hi all!
I've got function "function assign_rand_value" that makes random ID wich is primary key. I was interested in making loop with database to make primary key that is not already in database
I know it goes with "while" but don't know how to make it with database.
Please if somebedy can help me or give me right direction in tutoral
Loop
Moderator: General Moderators
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
Code: Select all
function blah(){
$key = make_your key here
$result = mysql_query("SELECT count(id) FROM table WHERE id = '$key'");
$result = mysql_fetch_array($result);
if(!$result['count(id)']){
return $key;
}else{
blah();
}
}