Jump to content

Help altering random number query


Shamrox

Recommended Posts

I have this working query, but if it finds a duplicate number, I'd like it to continue looping thru until if finds a unique number. How would I alter this?

 

$sql = "SELECT pin FROM `pin_users` ORDER BY pin ASC";
$results = mysql_query($sql);
while($row = mysql_fetch_array($results, MYSQL_NUM)){
	$data[] = $row[0];
	$rando = rand(10000, 99999);
	}
	if (in_array($rando, $data)) {
    	echo "Got Dup";
}else{
		$rando;
	}

Link to comment
https://forums.phpfreaks.com/topic/110938-help-altering-random-number-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.