Jump to content

[SOLVED] PHP 'Loading...' HELP please


elvin.sh

Recommended Posts

:-\ 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

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.

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.