Filling Progress bar from players online query?
#1

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>
Reply
#2

Код:
<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.
Reply
#3

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!
Reply
#4

What do you mean it goes outside? I'm intrigued..
Reply
#5

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
Reply
#6

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.
Reply
#7

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
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)