kryppienation Posted December 16, 2008 Share Posted December 16, 2008 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 More sharing options...
ngreenwood6 Posted December 16, 2008 Share Posted December 16, 2008 I am sure that someone is willing to help you do this but you will have to start coding something and come back when you need help or cannot get it to work. nobody out there is just going to code it for you. Link to comment https://forums.phpfreaks.com/topic/137143-solved-progress-bar/#findComment-716385 Share on other sites More sharing options...
berry05 Posted December 16, 2008 Share Posted December 16, 2008 here's a guide to operators if you need them...i think in a project like that you would need to use them... http://w3schools.com/php/php_operators.asp Link to comment https://forums.phpfreaks.com/topic/137143-solved-progress-bar/#findComment-716388 Share on other sites More sharing options...
ngreenwood6 Posted December 16, 2008 Share Posted December 16, 2008 You can also use mysql_num_rows to count the number of results you get from the query. That will be helpful to count the number of users. Link to comment https://forums.phpfreaks.com/topic/137143-solved-progress-bar/#findComment-716391 Share on other sites More sharing options...
kryppienation Posted December 16, 2008 Author Share Posted December 16, 2008 would i use css to do the actual bars? I am not asking anyone to code this for me, i just wanted to get a little advice on what to do. Link to comment https://forums.phpfreaks.com/topic/137143-solved-progress-bar/#findComment-716392 Share on other sites More sharing options...
berry05 Posted December 16, 2008 Share Posted December 16, 2008 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 More sharing options...
ngreenwood6 Posted December 16, 2008 Share Posted December 16, 2008 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 More sharing options...
kryppienation Posted December 16, 2008 Author Share Posted December 16, 2008 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 More sharing options...
ngreenwood6 Posted December 16, 2008 Share Posted December 16, 2008 no problem. I am glad that I could help. Link to comment https://forums.phpfreaks.com/topic/137143-solved-progress-bar/#findComment-716845 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.