Jump to content

[SOLVED] sleep()...hm (sorry for being vague! hard to explain)


Recommended Posts

Hi!

 

Right now all I'm doing is running a couple of tests to decide if what I'm trying to do can be done this way:

 

I have a while loop doing this:

while($row_email = mysql_fetch_array($result)) {

echo $row["my_field"].",";
sleep(10);

}

 

This is echoing: "0,0,0," because there are 3 rows in my table and all of them have a value of "0".

 

I put the sleep(10) there because I want to be able to change the value of one of the fields while the script is "asleep", so that it echoes that value out the next time it loops. So if I were to change the value of "my_field" to "1" after 1~10 seconds, it would echo "0,1,1," or something similar.

 

Basically what I want is to change the values that will be echoed after the script is done processing while the script is running.

 

Right now, theoretically, what I have should be enough right? am I missing something? Is this simply impossible? does sleep() not work the way I'm seeing?

 

Thanks!

all sleep does in this case is wait 10 seconds each time it loops through the entries to continue looping. How exactly are you changing the values? if it is in that script than having it sleep is entirely useless, because the PHP can't do anything while its "asleep"

 

I really dont understand what you wish to accomplish here

You would need to execute the query again to see any change in the database values because the result of the previous query is buffered in memory at the time the query was executed.

 

And with this said I conclude that I did not know what was going on in the background :)

 

Thanks, that worked! Even if I now have an extra query per item... hehe.. I'll live.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.