Help with Random Number and MYSQL integration

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Help with Random Number and MYSQL integration

Post 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);
}
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Moved to PHP Code. Not sure why this was hiding in Regex :)
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

Psuedo code:

before:

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

Inside function (after assigning the variable):

"INSERT $icvsn into cnvsn";
Post Reply