-
-
$stid = isset($_GET['stid'])?$_GET['stid']:0; - $endid = $stid + 100;
- $ maxid = 10000;
function dosomething(){
- //A time-consuming operation
- ...
- }
- $sql_string=”select * from `table` where id>'$stid ' and id<='$endid' order by id";
- $datas = getdata_bysql($sql_string);
- foreach($datas as $data){
- //Processing data
- …..
- echo $id." Processing Done.
”;
- if($id>=$maxid){exit;}
- }
- if($stid<=$maxid){
- $stid = $stid + 100;
- $url= "action.php?stid=$stid";
- echo $url;
- echo '';
- }
- ?>
-
-
Copy code
The dosomething() is a time-consuming operation. Here we reduce the running time by limiting the id range, and automatically run the next step through javascript jump after running.
In this way, you can know the results every time you process a batch of data, and if there is an interruption, you will also know where the problem lies.
|