elvin.sh Posted April 17, 2007 Share Posted April 17, 2007 :-\ Hi. I want echo like 'loading..' during, running of code... Ex:<? for ($i=0;$<100;$i++) { copy('1mb file', 'destination'); echo "Now loading $i rt file..<br>"; } ?> I see all of 'echo's after run.. how i can see this messages during running... Thanks... (Sorry for my English.) Link to comment https://forums.phpfreaks.com/topic/47401-solved-php-loading-help-please/ Share on other sites More sharing options...
soycharliente Posted April 17, 2007 Share Posted April 17, 2007 For the most part, PHP is a server side language that just returns data. When you run a block of code that returns/echos/prints anything, it will do all of the BEFORE loading the page. It will then load all of the data that it gathered and render it on the page. If you are looking for a loading screen, try looking into, Javascript or AJAX. Link to comment https://forums.phpfreaks.com/topic/47401-solved-php-loading-help-please/#findComment-231264 Share on other sites More sharing options...
elvin.sh Posted April 17, 2007 Author Share Posted April 17, 2007 I know AJAX.. I'm looking for during running.. It may will not be... but a had seen it before... It wasn't AJAX or other... I looked its base code... but i couldn't see any differents.. now i can't find the code... anyway... Thanks.. Link to comment https://forums.phpfreaks.com/topic/47401-solved-php-loading-help-please/#findComment-231282 Share on other sites More sharing options...
elvin.sh Posted April 18, 2007 Author Share Posted April 18, 2007 Hi. I found what i want..flush(); copy/past it.. you will love it.. <html> <head> <style type="text/css"><!-- div { margin: 1px; height: 20px; padding: 1px; border: 1px solid #000; width: 275px; background: #fff; color: #000; float: left; clear: right; top: 38px; z-index: 9 } .percents { background: #FFF; border: 1px solid #CCC; margin: 1px; height: 20px; position:absolute; width:275px; z-index:10; left: 10px; top: 38px; text-align: center; } .blocks { background: #EEE; border: 1px solid #CCC; margin: 1px; height: 20px; width: 10px; position: absolute; z-index:11; left: 12px; top: 38px; filter: alpha(opacity=50); -moz-opacity: 0.5; opacity: 0.5; -khtml-opacity: .5 } --> </style> </head> <body> <?php if (ob_get_level() == 0) { ob_start(); } echo str_pad('Loading... ',4096)."<br />\n"; for ($i = 0; $i < 25; $i++) { $d = $d + 11; $m=$d+10; //This div will show loading percents echo '<div class="percents">' . $i*4 . '% complete</div>'; //This div will show progress bar echo '<div class="blocks" style="left: '.$d.'px"> </div>'; flush(); ob_flush(); sleep(1); } ob_end_flush(); ?> <div class="percents" style="z-index:12">Done.</div> </body> </html> Unfortunetly i couldn't use flush for my code... i will try some other ways.... thanks... Link to comment https://forums.phpfreaks.com/topic/47401-solved-php-loading-help-please/#findComment-231950 Share on other sites More sharing options...
cyrixware Posted April 18, 2007 Share Posted April 18, 2007 nice one!... anyway thanks elvin.sh Link to comment https://forums.phpfreaks.com/topic/47401-solved-php-loading-help-please/#findComment-231953 Share on other sites More sharing options...
clown[NOR] Posted April 18, 2007 Share Posted April 18, 2007 yeah.. that was really nice=) Link to comment https://forums.phpfreaks.com/topic/47401-solved-php-loading-help-please/#findComment-231988 Share on other sites More sharing options...
soycharliente Posted April 18, 2007 Share Posted April 18, 2007 What is $m for? Link to comment https://forums.phpfreaks.com/topic/47401-solved-php-loading-help-please/#findComment-232226 Share on other sites More sharing options...
elvin.sh Posted April 19, 2007 Author Share Posted April 19, 2007 i copy past it from php.net.. i haven't got any idea... delete it Link to comment https://forums.phpfreaks.com/topic/47401-solved-php-loading-help-please/#findComment-232912 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.