Jump to content

[SOLVED] Progress Bar


kryppienation

Recommended Posts

I had an idea to make a progression of the current amount of user's in my database. What i would like to do is take 2 variables, the first variable is going to be the "totalgoal" of user's and the second variable is going to actually count the number of user's in my database. What i wanted to do was display a progress bar of the % of how close i am to reaching my usergoal.

 

EX. my total goal for users is going to be 1000 ($totalgoal), and my current amount of users is going to be 100 ($gettotalusers). I am wondering if someone can help me to understand how to make this display a bar with the current % i am to reaching my goal. In the example above, the bar would show me being at 10%. Would there be anyone out there willing to help me make this happen?

 

Thanks A Lot,

~Kryppie Nation

Link to comment
https://forums.phpfreaks.com/topic/137143-solved-progress-bar/
Share on other sites

im kind of new to php...and im just trying to help...but if you make a image of the bars and then do a if statement..and if the bars are at a certain level then show the image with a if statement..

 

$image = "urlofimage";

if ( $image == "number" ) {
echo $image;
}

 

 

or something like that

Link to comment
https://forums.phpfreaks.com/topic/137143-solved-progress-bar/#findComment-716397
Share on other sites

You could probably create something like this:

 


$goal = 1000;
$users = 100;

//that will output the percentage in this case 10%
$percent = $goal / $users;

//then make the table
echo "<table width='$percent'>";
echo "<tr>";
echo "<td style='background: repeat image.jpg'></td>";
echo "</td>";
echo "</table>";

 

If you were to do this I would make an image in photoshop or some other editor with a size of 1px. This will repeat it with the width being the percentage. The max size of this would be 100px. If you wanted it bigger you could multiply the $percentage by whatever you wanted the biggest to be. for ex.:

 

//this would equal 500
$percent = $percent *5

 

Please let me know if this helps.

Link to comment
https://forums.phpfreaks.com/topic/137143-solved-progress-bar/#findComment-716401
Share on other sites

Thank you very much ngreenwood6 your help was very helpful to me. This was a very easy way to do this, i knew if i asked i would be able to get someone who knew a better way to do this that to use a whole bunch of CSS... I don't understand the CSS very well.

 

 

For anyone else who just wants a progress bar of 2 variable numbers, this is the final code i ended up with for me purposes. For the live version i have substituted the $goal and $users with variables that i had obtained from query's.

 

 

<?php

$goal = 100;
$users = 20;


$percent = ($users / $goal) * 100;

$percent1 = $percent * 5;




echo '<table width="500"><tr><td align="center">We are now at '.$percent.'% of our member goal of '.$goal.' members.</td></tr></table>';

echo '<table background="./images/progressbar/whitetile.png" border="1" width="500"';
echo '<tr><td>';





echo "<table background='./images/progressbar/bluetile.png' border='1' width='$percent1'>";
echo "<tr>";
echo "<td></td>";
echo "</td>";
echo "</table>";

echo '</td></tr>';
echo '</table>';


?>

 

 

Thanks again to all of those who helped me out on this, and GL to anyone else who may have wanted something similar to this.

 

 

I have also included an upload of the output incase anyone wanted to see what this returns.

 

Thank You,

~Kryppie Nation

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/137143-solved-progress-bar/#findComment-716453
Share on other sites

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.