Php implements refresh to refresh the page to batch import data, refresh to refresh the page _ PHP Tutorial

Source: Internet
Author: User
Php implements refresh to refresh the page for batch data import, and refresh to refresh the page. Php implements refresh to refresh the page for batch data import. refresh page This article describes how php implements refresh to refresh the page for batch data import. We will share with you how to import data in batches on the refresh page of php, and refresh the page

This example describes how to batch import data on the refresh page of php. Share it with you for your reference. The specific analysis is as follows:

This function is based on the principle that dedecms generates html pages, but dedecms uses js redirection and refresh for redirection. The effect is the same, let's take a look at a php method to import data in batches.

Because it is definitely not feasible to import million data into the database at a time, so I will import 50 or more data at a time, next time, refresh again to solve the problem. The code is as follows:

The code is as follows:

<? Php
Set_time_limit (0 );
// Connect to the 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 ['Ms'];
$ 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' Processing data. the current value is '. $ s ......';
}
Else
{
Echo 'process all data and then sort it randomly ';
}
?>

I hope this article will help you with php programming.

Examples in this article describes how to import data in batches on the refresh page of php. I will share it with you for your reference...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.