Code: Select all
<?php
$numbers = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
for($i=0;$i<9;$i++) {
$number = array_rand($numbers, 1);
$rand_acc .= $number;
}
$q = "SELECT * FROM customers WHERE acc_no = '$rand_acc'";
$r = mysql_query($q, $connection);
if(mysql_num_rows($r) == "0") {
return TRUE;
} else {
return FALSE;
}
?>Though it might be impossible to get a duplicate, I just wouldn't want to take risks in having two different accounts with the same number.
-Nay