Jump to content

Recommended Posts

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 !

Link to comment
https://forums.phpfreaks.com/topic/158833-progress-bar-of-achievement/
Share on other sites

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

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

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 !

$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; }

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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