How php updates data

Source: Internet
Author: User
Question about the php Data update progress. This post was last edited by aier520 at 00:59:45, January 6 ,.

The update. php page is roughly as follows:

// The execution time of this page is relatively long, which may take several minutes $ SQL = "select * from news "; // run the SQL statement to obtain the array $ news_arr. the specific code is omitted. $ news_count = count ($ news_arr)-1. the number of arrays is counted, to calculate the update progress // start the loop array and update the data foreach ($ news_arr as $ key => $ value) {// obtain the data from another database and update it to the local data, code omitted $ _ SERVER ['wait'] = floor ($ key/$ news_count * 100); save the update progress to the session}


The getdata. php page is the update progress saved in the output session. the code is as follows:
echo $_SERVER['wait'];


The html page is roughly as follows:

When you click this button, a js (written by jquery) is triggered)
$ (". Bgn ,. bgy "). click (function () {url = "http: // localhost/update. php "; // data update operation page $. get (url); // use ajax to execute the update program function getwait () {$. get ("http: // localhost/getdata. php ", // obtain the data update progress function (redata) {// The problem lies in the above $. get (url) to execute the update, // if the php update script is not completed (that is, update. the php program on this page is not executed), // no data is returned here. may I ask my friends, how can I solve this problem? Alert (redata); // update progress bar processing}, "text")} setInterval (getwait, 1000 );})



Reply to discussion (solution)

You need to make a progress bar and make a timer at the front end to submit the data and return the result to submit 10% at a time... you don't have to say that.

PHP progress bar

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.