[eluser]austintbiggs[/eluser]
I'm currently working on a membership feature of my website. Specifically I've tried a few combinations and I'm still struggling.
The feature includes a unique user id (6 digit) created by the mt_rand function; what I'm stuck on is the conditional statement to check the database to see if the number already exists inside the table 'membership' and if so generate a new number and recheck the table, continuously looping until a unique number has been generated then store it as a key 'userID'.
Essentially (Or something of the sort):
Code:
$user_id = mt_rand(000001, 999999);
if $user_id exists within membership
$user_id = mt_rand(000001, 999999);
$insert = $this->db->insert('membership', $user_id);
Any and All help is appreciated [: