Jump to content

Counting 1-?


komquat

Recommended Posts

I have a table, and I want this to show who is ranked #1 thru rank # 19. I have it in a loop, so I would use it like this
[code]
<?php
for ($i = 1; $i <= 19; $i++)

//Loop is here
while(Somefunction Here) {
<td>$i</td><td>$player</td><td>$points</td>
}

?>
[/code]

Would I need a ';' after the for() statement?
Link to comment
https://forums.phpfreaks.com/topic/3747-counting-1/#findComment-13003
Share on other sites

[!--quoteo(post=350259:date=Feb 28 2006, 11:29 AM:name=kanikilu)--][div class=\'quotetop\']QUOTE(kanikilu @ Feb 28 2006, 11:29 AM) [snapback]350259[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[code]<?php
for ($i = 1; $i <= 19; $i++) {
  echo "<td>$i</td><td>$player</td><td>$points</td>";
}
?>[/code]
[/quote]

How would I put count loop inside of the While loop?
Link to comment
https://forums.phpfreaks.com/topic/3747-counting-1/#findComment-13058
Share on other sites

Wait a minute! Where does the information actually come from about player names and score (or whatever is used to rank them)? If it's from a database then you can construct a single query to retrieve the highest 19 scores, ordered by score .... Bit more information please, then we'll figure out what this has to do with a while loop, or a for loop, or a counter.
Link to comment
https://forums.phpfreaks.com/topic/3747-counting-1/#findComment-13063
Share on other sites

[!--quoteo(post=350299:date=Feb 28 2006, 12:50 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Feb 28 2006, 12:50 PM) [snapback]350299[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Wait a minute! Where does the information actually come from about player names and score (or whatever is used to rank them)? If it's from a database then you can construct a single query to retrieve the highest 19 scores, ordered by score .... Bit more information please, then we'll figure out what this has to do with a while loop, or a for loop, or a counter.
[/quote]

I am getting it from a DB, and I currently do that, but I want a rank for each one as well as the order.

I have:

Andy 10
Bob 12
Tony 14
John 22

I want them to have a rank in front of them.
Link to comment
https://forums.phpfreaks.com/topic/3747-counting-1/#findComment-13066
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.