Home > Backend Development > PHP Tutorial > PHP implements refresh refresh page method to import data in batches, refresh refresh page_PHP tutorial

PHP implements refresh refresh page method to import data in batches, refresh refresh page_PHP tutorial

WBOY
Release: 2016-07-13 10:11:02
Original
681 people have browsed it

php implements refresh refresh page method to import data in batches, refresh refresh page

The example in this article describes the method of batch importing data in PHP to refresh the page. Share it with everyone for your reference. The specific analysis is as follows:

This function refers to the principle of dedecms to generate html pages, but dedecms uses js to jump and I use refresh to jump. The effect is the same. Let's take a look at a method of batch importing data in PHP. .

Because I have 1000W data to import into the database at one time, it is definitely not feasible, so I imported 50 or more pieces of data each time, and then refreshed it next time to solve this problem. The code is as follows:

Copy code The code is as follows:
set_time_limit(0);
//Connect to database

$s = isset( $_GET['s'] )?$_GET['s']:0;
$e = isset( $_GET['e'])?$_GET['e']:50;
$count =85000;

if( $s < $count )
{
$sql = "select * from bac_info where isget =0 order by id desc limit $s,$e ";
$query = mysql_query( $sql );
while( $rs = mysql_fetch_array( $query ) )
{
$id = $rs['id'];
$sms = $rs['sms'];
$typeid = $rs['typeid'];
$isget = $rs['isget'];
$sql = "insert into bac_info_bak (id,sms,typeid,isget) values('$id','$sms','$typeid','$isget')";
mysql_query( $sql ) ;
echo $sql;
//exit;
$sqlu = "update bac_info set isget=1 where id =".$rs['id'];
mysql_query( $sqlu );
}
echo 'Data is being processed, currently '.$ s.'Article. . . . . . ';
}
else
{
echo 'Complete all data processing Randomly sort again';
}
?>

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/932070.htmlTechArticlephp method to implement refresh refresh page to import data in batches, refresh refresh page This article tells the example of php to implement refresh refresh page in batches How to import data. Share it with everyone for your reference...
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