我只要一加入以下代码 网页加载就很慢 然后就会出现这个错误提示: Fatal error: Maximum execution time of 30 seconds exceeded in E:\xampp\htdocs\business\lib\functions.php on line 13
- PHP code
$rand_invoice_id=rand(0000,9999); $current_time=date("Y-m-d H:i:s"); $current_time_start=date("Y-m-d")." "."07:00:00"; $tomorrow_time_start=date("Y-m-d", strtotime('+1 day'))." "."07:00:00"; $yesterday_time_start=date("Y-m-d", strtotime('-1 day'))." "."07:00:00"; $row=1; do { $query="SELECT * FROM CART WHERE (invoice_id='$rand_invoice_id') AND (order_time BETWEEN '$current_time_start' AND '$tomorrow_time_start')"; $result=queryMysql($query); $rows=mysql_num_rows($result); if($rows != 0) { $rand_invoice_id=rand(0000,9999); } } while($row!=0);
我只是想弄一个购物车,随机生成invoice ID,但是随机生成的可能会重复,所以先随机生成一个,然后在数据库里一定时间范围内找,如果有一样的就重新随机再生成一个,知道没有重复为止。
我实在不知是哪有问题了,谢谢各位!替我看看吧
------解决方案--------------------
$row=1;
do
{
......
$rows=mysql_num_rows($result);
.....
}
while($row!=0);
死循环!$row!=0 条件永远满足