Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Timing on a loop..

Posted on 2008-10-01
3
Medium Priority
?
214 Views
Last Modified: 2008-10-02
$result = mysql_query($query);
echo mysql_error();
 while($row = mysql_fetch_array($result)){
        $search = $row[0];
        echo $search;

I have this.  The final result will be different but I will be able to illustrate my question.   I want to loop the results one by one, one every 15 second and then the next row.  What would be the best way to do this?  For the end result I'll strictly be doing stuff that doesn't display on the screen but I'm not sure what the consequences are of running a loop with potentially thousands of records in a database.

.. Is it even possible to add timing to a php while loop..
0
Comment
Question by:cstormer
  • 2
3 Comments
 
LVL 27

Expert Comment

by:Cornelia Yoder
ID: 22621012
$result = mysql_query($query);
echo mysql_error();
 while($row = mysql_fetch_array($result)){
        $search = $row[0];
        echo $search;
        sleep(15);
}
0
 

Author Comment

by:cstormer
ID: 22621161
This does work, when it's finish with the whole query it displays.

What are the concequences of running this against a few thousand records?
0
 
LVL 27

Accepted Solution

by:
Cornelia Yoder earned 2000 total points
ID: 22623120
It will take a few thousand x 15 seconds to run the script.  The query is done only only once, so the time is not of consequence to the database.  However, you may need to set your php time limit to ensure the program continues running.

set_time_limit(150000);

You may also need to check with your webhost or the server settings to ensure that this will work.  I'm not personally familiar with how the time limits are enforced.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question