samoi Posted May 19, 2009 Share Posted May 19, 2009 Hello guys, I'm trying to do a progress par of an achievement. it's kind of count down, but with graphic and stuff. Let's say I'm waiting until one week from now to go somewhere, and so excited about it. I need to build a script that matches time still until that week, and a bar or graphic decreases with the time goes down until that week. let's say I'm checking the script now, it should be for example: 0% |||||||||||||||||||||||||||||| 100% OR 0% :(:(:(:(:(:( 100% Then before the specific day comes by one night it should look something like 0% |||||||||||||||||||||||||||||| 100% OR 0% :):):):):):) 100% I hope you got the idea ! I have written the count down but "Numeric count down". But really don't know how to do that designedly. Thank you all ! Quote Link to comment https://forums.phpfreaks.com/topic/158833-progress-bar-of-achievement/ Share on other sites More sharing options...
sKunKbad Posted May 19, 2009 Share Posted May 19, 2009 you could use strtotime('now') over a preset time of completion, and then convert that fraction to a decimal (percentage). Quote Link to comment https://forums.phpfreaks.com/topic/158833-progress-bar-of-achievement/#findComment-837751 Share on other sites More sharing options...
MadTechie Posted May 19, 2009 Share Posted May 19, 2009 Try this okay the session stuff isn't needed but was fun for an example, just put this code into a single file and run it, if its what you want then play with it, if not delete it <?php session_start(); if(!empty($_SESSION['counter']) || $_SESSION['counter']==100) { $_SESSION['counter']++; }else{ $_SESSION['counter']=1; } $barwidth = 300; $done = $_SESSION['counter']; $donewidth = ($barwidth/100)*$done; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="REFRESH" content="2"> </HEAD> <title>ProcessBar</title> <style type="text/css"> <!-- .processbox{ width: <?php echo $barwidth;?>px; background-color:#FFF; border:thin #000; border-style:solid; height: 10px; } .bar{ background-color:#0C0; height: 10px; width: <?php echo $donewidth;?>px; } --> </style> </head> <body> <div class="processbox"> <div class="bar"></div> </div> <br> <?php echo $done;?> % done </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/158833-progress-bar-of-achievement/#findComment-837756 Share on other sites More sharing options...
Maq Posted May 20, 2009 Share Posted May 20, 2009 MadTechie the loading script doesn't stop at %100, lol. Quote Link to comment https://forums.phpfreaks.com/topic/158833-progress-bar-of-achievement/#findComment-837759 Share on other sites More sharing options...
MadTechie Posted May 20, 2009 Share Posted May 20, 2009 LOL change if(!empty($_SESSION['counter']) || $_SESSION['counter']==100) to if(!empty($_SESSION['counter']) && $_SESSION['counter']<100) to make it start over, the build up was just for showing that i don't test my code Quote Link to comment https://forums.phpfreaks.com/topic/158833-progress-bar-of-achievement/#findComment-837762 Share on other sites More sharing options...
samoi Posted May 20, 2009 Author Share Posted May 20, 2009 Thank you all for helping me out. But this is not exactly what I'm really looking to figure! This one is using session, so the progress bar will pause when I close the page, and resume when I open the page! I need this to keep going as it counts at the server side not the browser. I hope you got what I mean. Also if you want me to provide you with the count down code, I will do it. Thank you all, and I really appreciate your help ! Quote Link to comment https://forums.phpfreaks.com/topic/158833-progress-bar-of-achievement/#findComment-837902 Share on other sites More sharing options...
MasterACE14 Posted May 20, 2009 Share Posted May 20, 2009 lol he used a session just to quickly show you how it can be done. Replace the session variables with your own from your database or where ever they are stored. Quote Link to comment https://forums.phpfreaks.com/topic/158833-progress-bar-of-achievement/#findComment-837911 Share on other sites More sharing options...
samoi Posted May 20, 2009 Author Share Posted May 20, 2009 Thanks for replying, But I'm using a function calculation like countdown(year, month, day, hour, min); I'm really looking for your help guys ! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/158833-progress-bar-of-achievement/#findComment-838402 Share on other sites More sharing options...
POG1 Posted May 20, 2009 Share Posted May 20, 2009 $finish = 94438384; // timestamp of when it finishes $width = time() / $finish; if($width > 1) { $width = 1; } echo '<div id="outer">'. '<div id="inner" style="width:'.$width.'%;">'. '</div>'. '</div>'; CSS div#outer { height:10px;width:200px;background:#900;padding:0; } div#inner { height:10px;background:#090;margin:0;padding:0; } Quote Link to comment https://forums.phpfreaks.com/topic/158833-progress-bar-of-achievement/#findComment-838414 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.