Filling Progress bar from players online query? -
SparkyCode - 05.10.2015
Hi, i was wondering if somebody knew how to accomplish this kind script for a bootstrap 3 progress bar.
Thanks!
EDIT: Managed to parse the array number alone, i still wonder how to integrate it to a Bootstrap 3 Progress bar.
Current Code:
Код:
<?
$players = $query->
if ($query->
$query->getInfo();
$query->
echo $players['players'];
?>
And i need to integrate it with this:
Код HTML:
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%;">
<span class="sr-only">60% Complete</span>
</div>
</div>
Re: Filling Progress bar from players online query? -
StuartD - 05.10.2015
Код:
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="<?php echo $players['players']; ?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo $players['players']; ?>%;">
<span class="sr-only"><?php echo $players['players']; ?> current players</span>
</div>
</div>
If you get the max players too, set aria-valuemax=MAX PLAYERS
This won't update live though, it'll only show the up to date when you reload the page.
Re: Filling Progress bar from players online query? -
SparkyCode - 05.10.2015
That did work, i kinda feel a bit dumb for not realizing how easy it was. Although i get my progress bar to go outside my container because of the width.. anyways will post that on Stack Overflow i guess.
Thanks for claryifing how it was done!
Re: Filling Progress bar from players online query? -
StuartD - 05.10.2015
What do you mean it goes outside? I'm intrigued..
Re: Filling Progress bar from players online query? -
SparkyCode - 05.10.2015
Quote:
Originally Posted by StuartD
What do you mean it goes outside? I'm intrigued..
|
Because the Value is so high, my progress bar decides to go outside my Medium Column container and.. well.. doesn't need much explanation xD
Re: Filling Progress bar from players online query? -
Vince - 05.10.2015
I hope you realize you need to scale it to 100%? If there are say 354 of 500 players online then you obviously don't put 354 directly in the HTML. 354/500 players = 70.8% filled and
that's the number you output in HTML.
The code you posted makes no sense at all and is not even syntactically correct. I think the guys at StackOverflow would have a good laugh.
Re: Filling Progress bar from players online query? -
SparkyCode - 05.10.2015
Quote:
Originally Posted by Vince
I hope you realize you need to scale it to 100%? If there are say 354 of 500 players online then you obviously don't put 354 directly in the HTML. 354/500 players = 70.8% filled and that's the number you output in HTML.
The code you posted makes no sense at all and is not even syntactically correct. I think the guys at StackOverflow would have a good laugh.
|
Yes, you are certainly right. As i was reading the code to do another thing i realize what you just said, i have to admit that it has been such a rough week working on lots of projects and it seems that i went over the top.
Now, what would be the best way to scale it to those points while using PHP and without breaking the progress bar?
I know a few things that i could make (just thinking of them) but im not very php savvy to achieve it U_U