Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display loading percentage and how to do it without javascript?

I want to make something similar to loaders in PHP so I used this code:

<?php 
$x=1;
while($x<=100) {
   echo "Loading: $x %<br>";
   $x++;
}   
?>

So that it would display from "Loading 1%" to "Loading 100%". But this will result in all appearing one at a time without disappearing after the new line appears. So I want to know how to make the new line appear and the old disappear and this starts after the page loads, so the user will be able to watch a loader actually loading from 1% to 100%.

UPDATE: I know I should use JS and/or Ajax to achieve it, I just wanted to know if there's a way to also do it in PHP :)

like image 706
Marwan Ossama Avatar asked Apr 25 '14 21:04

Marwan Ossama


1 Answers

PHP is a server side language and it give you response based on request .

you can not manipulate (like you want) on DOM .

for this you should use javascript and AJAX to change DOM elements based on PHP result

like image 75
Anri Avatar answered Oct 02 '22 18:10

Anri