How does MySQL PHP read data cyclically from the database in batches?
迷茫
迷茫 2017-07-01 09:11:51
0
2
767

If five items are read from the database each time, how should the program continue to loop until all loops are completed.
add a

$a = true;
//然后用while循环
//在数据库里设计个字段,为判断有没有取出来过这条数据的字段,默认为没取出来过
//然后用foreach把每次取出来的每条数据都标记为已取出过,直到所有数据都被标记为已取出过来,循环停止。

Is this logic correct?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(2)
过去多啦不再A梦

You use limit. Then record the id until the id is greater than maxid, right?

小葫芦

You can use the principle of paging query. .

$count = '100';//总条数
$strip = 0;
$num = $count/5;//循环多少次
for($i=1;$i<=$num;$i++)
{
 $sql = "select * from `table` order by id limit ".$strip.",5";
 $strip += 5;
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template