I need a php script that will generate an ID, check the mysql database if the ID is used or not. If the ID is already used it should automatically try another (new) ID, it should try an ID until no match can be made.
The ID would be a simple random number:
$user_id = rand(100000,10000000000)
The database should check table `users`, and field `user_id`