Page 1 of 1

Help with Random Number and MYSQL integration

Posted: Mon May 29, 2006 3:53 pm
by tecktalkcm0391
Ok, I have need this to happen:

A user signs up then the computer picks a random 9 digit number from 11111111-99999999, goes in to the database to make sure I doesn't exist already, and if it doesn't i give them that 9 digit number. This is what I have so far.

Code: Select all

if($cnvsn == $icnvsn) {
	generate_vsn();
	} else {
	$nvsn = $cnvsn;
	}

}

function generate_vsn()
{
$cnvsn = rand(1111111111, 999999999);
}

Posted: Mon May 29, 2006 3:55 pm
by Chris Corbyn
Moved to PHP Code. Not sure why this was hiding in Regex :)

Posted: Mon May 29, 2006 4:10 pm
by Roja
Psuedo code:

before:

$results = "SELECT * from cnvsn where number=" . $icnvsn;

Inside function (after assigning the variable):

"INSERT $icvsn into cnvsn";