PHP loop-php Tutorial

Source: Internet
Author: User
For PHP loop problems, there is a data table with the job field: idnamecontentdate. premise: scrapy writes data to the database job table every moment. problem: the last data is read from the job table every minute, compared with the current time, if the current time is 30 minutes different from the date field data time, the loop will jump out. otherwise, will the while loop be used to create an endless loop? How to do this. Thank you ------ solution ---- PHP loop problem
There is a data table named job field: id name content date

Prerequisites:
Scrapy writes data to the database job table every moment.

Problem:
Read the last data from the job table every minute,
Compare with the current time. if the difference between the current time and the date field data time is 30 minutes, it will jump out of the loop; otherwise, it will continue.

Do I use a while loop to create an endless loop? How to do this. Thank you.



------ Solution --------------------
While (1 ){
$ SQL = "select * from job order by id desc limit 1 ";
$ Rs = mysql_query ($ SQL );
$ Date = mysql_fetch_array ($ rs );
$ Time_shijiancha = time ()-$ date ['Date'];
If ($ time_shijiancha> 30 ){
Break;
} Else {
Sellp (1); # I don't know if this function works!
}
}
# Prerequisites:
# Scrapy writes data to the database job table every moment
----- Is this still unexpected? Why can't I write data for a certain period of time?

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.