Looping through query results and call a function for each - function contains sleep command
Bit of an odd one and I don't know if I am just over complicating the m开发者_如何学Pythonatter in my head. I have a query that will return a few results and a function that goes through a for loop and sleeps for 10 seconds at the end of every iteration.
What I need to do is loop through the query result calling this function for all the results. With the sleep in there, I believe it will only process the second query result when the for loop has finished for the first one. Does this make sense? i.e
while($row = mysql_fetch_array($query)
{
myFunctionThatCallsSleep6Times($row['Id']);
}
So the second result will only get called after the first result has finished but I need to start this function for each of the results at the same time.
Sorry if I am being unclear and thanks.
Resolved. I have restructured my code so that the query is done inside the for loop that contains the sleep command. So it loops through all the results per sleep.
精彩评论