请问高人看看这段代码那里错了,运行结果死循环

WBOY
Release: 2016-06-13 12:18:31
Original
892 people have browsed it

请教高人看看这段代码那里错了,运行结果死循环。
$result=mysql_query("SELECT * FROM st where cid = 1");
$max_num=mysql_num_rows($result);//取得数据库的记录数 
srand((double)microtime()*10000000); //生成随机数种子。 


$se_pos=rand(0, $max_num-1); //从0到最大记录数取随机数 
$length=1; //设定共取多少条记录 
//下面是取出指定数目的记录。 
$result_lim=mysql_query("select * from st  where cid = 1 limit $se_pos,$length"); 
$myrow_lim=mysql_fetch_array($result_lim); 


$se_pos1=rand(0, $max_num-1);
$result_lim1=mysql_query("select * from st  where cid = 1 limit $se_pos1,$length"); 
$myrow_lim1=mysql_fetch_array($result_lim1);


while($myrow_lim=$myrow_lim1) {
$se_pos1=rand(0, $max_num-1);
$result_lim1=mysql_query("select * from st  where cid = 1 limit $se_pos1,$length"); 
$myrow_lim1=mysql_fetch_array($result_lim1);



------解决思路----------------------
$result_lim1=mysql_query("select * from st  where cid = 1 limit $se_pos1,$length");  //除非出错,总是返回至少包含一条记录的结果集
$myrow_lim1=mysql_fetch_array($result_lim1);//所以 $myrow_lim1 总是为非空的数组

既然 $myrow_lim1 非空,那么这个循环怎么会终止呢?
while($myrow_lim=$myrow_lim1) {

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template