mrherman Posted September 16, 2010 Share Posted September 16, 2010 Good evening -- My script takes a while to execute as it processes records from the db. I'd like to have it print out to the screen the record id # as it processess each record, just to let me know where it is. Currently, the program waits till the end and then prints out the record numbers, which is no help. How can I enable PHP to print out each record number as it goes along? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/213539-forcing-php-to-echo-information-as-it-executes/ Share on other sites More sharing options...
WatsonN Posted September 16, 2010 Share Posted September 16, 2010 Use while to run while its doing the database work. More info: http://php.net/manual/en/control-structures.while.php Quote Link to comment https://forums.phpfreaks.com/topic/213539-forcing-php-to-echo-information-as-it-executes/#findComment-1111552 Share on other sites More sharing options...
mrherman Posted September 16, 2010 Author Share Posted September 16, 2010 Thanks for your reply...I have tried to place an ECHO statement inside the WHILE loop, but it still waits until the end of processing and then prints out all the record numbers at one time, rather than doing it as it processes each record... Quote Link to comment https://forums.phpfreaks.com/topic/213539-forcing-php-to-echo-information-as-it-executes/#findComment-1111554 Share on other sites More sharing options...
WatsonN Posted September 16, 2010 Share Posted September 16, 2010 Could you post the code so we can rake a look at it? Quote Link to comment https://forums.phpfreaks.com/topic/213539-forcing-php-to-echo-information-as-it-executes/#findComment-1111556 Share on other sites More sharing options...
Zane Posted September 16, 2010 Share Posted September 16, 2010 This is called flushing the output buffer. Take a read on it here.. http://www.tuxradar.com/practicalphp/13/9/0 Quote Link to comment https://forums.phpfreaks.com/topic/213539-forcing-php-to-echo-information-as-it-executes/#findComment-1111561 Share on other sites More sharing options...
chintansshah Posted September 16, 2010 Share Posted September 16, 2010 Hello, Your query saved as a resource id. To check and debug of your query output. use, var_dump($query); or you can use, print_r($query); You get the all rows details with data as an array. Quote Link to comment https://forums.phpfreaks.com/topic/213539-forcing-php-to-echo-information-as-it-executes/#findComment-1111567 Share on other sites More sharing options...
mrherman Posted September 16, 2010 Author Share Posted September 16, 2010 Ahaa! That is it! Thank you all for responding. Yes, that is it. One learns something new every day!! Quote Link to comment https://forums.phpfreaks.com/topic/213539-forcing-php-to-echo-information-as-it-executes/#findComment-1111571 Share on other sites More sharing options...
chintansshah Posted September 16, 2010 Share Posted September 16, 2010 Your welcome mrherman... Quote Link to comment https://forums.phpfreaks.com/topic/213539-forcing-php-to-echo-information-as-it-executes/#findComment-1111577 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.