Welcome Guest, Not a member yet? Register   Sign In
Database Helper & Conditions
#1

[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 [:


Messages In This Thread
Database Helper & Conditions - by El Forum - 04-11-2011, 05:22 PM
Database Helper & Conditions - by El Forum - 04-11-2011, 07:59 PM
Database Helper & Conditions - by El Forum - 04-12-2011, 01:50 PM
Database Helper & Conditions - by El Forum - 04-12-2011, 04:13 PM



Theme © iAndrew 2016 - Forum software by © MyBB