下面是我使用的代码
Again:
$rand = mt_rand(100000,999999);
$sql = "select * from replogins where access_code = $rand";
$res = mysql_query($sql);
if(mysql_num_rows($res))
goto Again;请帮帮忙
发布于 2011-04-28 19:38:05
你可以很容易地用一个while循环替换goto,解决你的问题,同时摆脱那个goto。;)
do {
$rand = mt_rand(100000,999999);
$sql = "select * from replogins where access_code = $rand";
$res = mysql_query($sql);
} while(mysql_num_rows($res));发布于 2011-04-28 20:00:51
做的时候真的很丑陋。
为什么不随机选择一行呢?
Select * from replogins order by RAND()https://stackoverflow.com/questions/5817894
复制相似问题