malcolmk Posted August 23, 2010 Share Posted August 23, 2010 Hi all, first time here and desperate. I have a host with php enabled so I figure why not use it as folks can turn off javascript. I am testing on a wamp windows setup. What I want to do is output an image or text to a div in a page, pause for 3 seconds then output a new pic or text to overwrite it. The code I am playing with is this. <html> <head><title></title></head> <body> <h1>what is this?</font></h1> <?php echo '<div id="main" style=" position: absolute; top:100; left: 100; width: 100px; height: 70px; visibility: show;"> my div content is here </div>'; //for ($x=0;$x<30000;$x++){} sleep(3); echo '<div id="main" style=" position: absolute; top:100; left: 100; width: 100px; height: 70px; visibility: show;"> new content now </div>'; ?> </body> </html> Firstly the second text output merges with the first ! can I destroy a div and then recreate it to get a clear canvas? BUT the thing I cant do is pause the output, as you see above I have tried an empty counting loop and the sleep function. Neither work as the pause happens before ANY output and then the div shows up with the merged outputs? Anyone explain to me how to do this and why does the sleep not occur wher it is placed? Thanks for your help people. Quote Link to comment https://forums.phpfreaks.com/topic/211482-cant-pause-script-output/ Share on other sites More sharing options...
kickstart Posted August 23, 2010 Share Posted August 23, 2010 Hi You server sends the details to the web page and then the web page displays them. What you have done is put a delay in the middle of generating the data. To put the delay on the web page would probably be easiest with javascript. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/211482-cant-pause-script-output/#findComment-1102637 Share on other sites More sharing options...
malcolmk Posted August 23, 2010 Author Share Posted August 23, 2010 So what you are saying is thet the browser waits to get the whole page before outputting so that the browser waits whilst php sleeps then gets the rest of the page and outputs it all in one go? Guess it makes sense when I think of it. If I use one script to output 2 seperate html pages of code , would that work? Gonna try it and see, thanks for your prompt help. Quote Link to comment https://forums.phpfreaks.com/topic/211482-cant-pause-script-output/#findComment-1102638 Share on other sites More sharing options...
malcolmk Posted August 23, 2010 Author Share Posted August 23, 2010 Well tried it with following code but does not output 2 seperate pages as I expected, simply merges the divs but the heading is displaced to a lower position? Guess php is not so easy, probably have to use javascript but like I say folks can turn that off. <?php echo '<html> <head><title></title></head> <body> <h1>what is this?</font></h1> <div id="main" style=" position: absolute; top:100; left: 100; width: 100px; height: 70px; visibility: show;"> my div content is here </div> </body> </html>'; sleep(10); echo '<html> <head><title></title></head> <body> <h1>what is this?</font></h1> <div id="main" style=" position: absolute; top:100; left: 100; width: 100px; height: 70px; visibility: show;"> new contenthere now </div> </body> </html>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/211482-cant-pause-script-output/#findComment-1102644 Share on other sites More sharing options...
MadTechie Posted August 23, 2010 Share Posted August 23, 2010 this is not a job for PHP, its a client side job IE javascript! Quote Link to comment https://forums.phpfreaks.com/topic/211482-cant-pause-script-output/#findComment-1102645 Share on other sites More sharing options...
malcolmk Posted August 23, 2010 Author Share Posted August 23, 2010 Think I have realised that now, thanks for replies. I guess I will learn a lot about the yes and no of php as I try to implement stuff and its probably the best way to learn, Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/211482-cant-pause-script-output/#findComment-1102651 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.