mysqli new mysqli хост юзер пасс база flag true do num rand 100 mysqli

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<?
$mysqli = new mysqli('хост', 'юзер', 'пасс', 'база');
$flag = true;
do {
$num = rand(1, 100);
$q = $mysqli->fetch_assoc($mysqli->query("SELECT COUNT(uniq_number) AS pizda FROM huj WHERE uniq_number = '$num'"));
if($q['pizda'] == 0)
$flag = false;
}while($flag);
//тут юзай $num
?>