Jump to content

Archived

This topic is now archived and is closed to further replies.

komquat

Counting 1-?

Recommended Posts

It is a pretty simple thing, or at least I thought, but I can not remember how to get sequential numbers

Ex.

1 A
2 B
3 C
4 D

I think it is something like

count=($i = '1', $i++);

Help or direction on this would be great.

Thanks

Share this post


Link to post
Share on other sites
are you just referring to for()?
[code]
<?php
for ($i = 1; $i <= 10; $i++)
  echo $i . "<br />\n";
?>
[/code]

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
[code]<?php
for ($i = 1; $i <= 19; $i++) {
  echo "<td>$i</td><td>$player</td><td>$points</td>";
}
?>[/code]

Share this post


Link to post
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?

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.