The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. November 19, 2008, 04:47:31 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: PHP Loading bar  (Read 194 times)
dbrown
Rookie
**
Offline Offline

Posts: 28


View Profile
« on: July 24, 2008, 07:14:12 PM »

This may be useless here, but this is the first loading bar I have seen done with php "only". I have seen plenty of loading bars with the help of, perl, ajax, flash, etc.

Code:
<html>
<head>
<style type="text/css"><!--

.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*'%&nbsp;complete</div>';
    
//This div will show progress bar
    
echo '<div class="blocks" style="left: '.$d.'px">&nbsp;</div>';
    
flush();
    
ob_flush();
    
sleep(1);
}
ob_end_flush();
?>

<div class="percents" style="z-index:12">Done.</div>
</body>
</html>
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 5136


:sniffle: Humor was so much easier before.


View Profile
« Reply #1 on: July 24, 2008, 08:30:51 PM »

Ah I get it ... interesting. Personally I'm an AJAX progressbarster, but this is a nice serverside hack. Usage would be more tricky though ... integrating it with something else would be a little ticklish.

Thanks the DB!
Logged

If I can't be Mr. Root then I don't want to play.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!