Php processes database data. Each time a data is processed, it returns the method in which the client displays the current status ., Current Database status
Php processes a large amount of data. Each time a piece of data is processed, the method returned to the client to display the current status.
Similar to dedecms for generating static pages
Idea:
Experiment process:
1. create databases and tables
create databases handle;create table user(id int unsigned not null auto_increment primary key,name varchar(8),sex tinyint(1) default '1',score int not null,state tinyint(1));
2. Add data to the table (not for example)
3.create the index.html client, a. php server 1, B. php server 2
Index.html:
<! DOCTYPE html>
A. php:
<? Php require ('. /dbconfig. php '); $ link = mysql_connect (HOST, USER, PASS) or die ('database link failed'); mysql_select_db (DBNAME ); /* query data $ SQL = "select * from user"; $ result = mysql_query ($ SQL); $ row = mysql_fetch_assoc ($ result); var_dump ($ row ); * // * cyclically insert for ($ I = 3; $ I <= 100; $ I ++) {$ SQL = "insert into user (name, score, state) values ('z ". $ I. "',". $ I. ", 1)"; mysql_query ($ SQL);} * // * Total Number of data to be processed * // isset ($ _ GET ['state'])? $ _ GET ['state']: 0; if (isset ($ _ GET ['state']) {$ SQL = "select count (*) from user "; $ result = mysql_query ($ SQL); $ all = mysql_result ($ result, 0); $ now = 0; header ("Location: B. php? All = {$ all} & now = 0 ");} else {header (" Location: B. php? All = {$ _ GET ['all']} & now = {$ _ GET ['now ']} ");}/* return the data currently processed */
B. php:
<? Php require ('. /dbconfig. php '); $ link = mysql_connect (HOST, USER, PASS) or die ('database link failed'); mysql_select_db (DBNAME ); /* return the currently processed data * // $ id = $ _ GET ['id']; // obtain the id $ now =$ _ GET ['now ']; // number of processed items $ all =$ _ GET ['all']; // total number of tasks to be processed $ SQL = "select score from user limit {$ now}, 1"; $ result = mysql_query ($ SQL ); $ value = mysql_result ($ result, 0); $ now ++; $ arr = array ('right' => $ now, 'all' => $ all, 'value' => $ value); // print_r ($ arr); echo json_encode ($ arr );
Dbconfig. php:
<?phpdefine('HOST','127.0.0.1');define('USER', 'root');define('PASS','root');define('DBNAME','handle');
All of the above ~