なぜそれが であるかは述べていませんが、not working私の推測では、//insert into events table以下のコードでは で を使用し$newEventIdてINSERTいます。$newEventId(mysql_num_rows(mysql_query("SELECT id FROM events WHERE EventID=$gen" )) == 0)truetrue
の値を返し、break代わりにそれを使用してみてください$newEventId
function EventId($gen)
{
if (mysql_num_rows(mysql_query("SELECT id FROM events WHERE EventID=$gen" )) == 0) {
return $gen; // return the number that will be set as $EventId and used in the insert
break;
}
// recall function
else
{
$newEventId = rand(1000, 10000);
EventId($newEventId);
}
}
$newEventId = rand(1000, 10000);
$EventId = EventId($newEventId); // set the returned $gen to $EventId to be used in the Insert query
//insert into events table
mysql_query("INSERT INTO events ... EventID=$EventId..");