Jump to content

row position


Minase

Recommended Posts

hello i need something like this

 

SELECT * FROM USERS ORDER BY GOLD DESC

 

it will return something like this

 

ID GOLD

3 555

1 400

2 100

 

 

how can i return the row place for ID 2 which have 100 gold

ID 3 = place 1

ID 1 = place 2

how can i do that?

thank you

Link to comment
Share on other sites

Create a counter in PHP when you retrieve and iterate through the results.  I am not sure if there is a way to do what you're asking, but that's something you could google.

 

$result = mysql_query($sql);
$i = 0;
while( $row = mysql_fetch_array($result) ) {
  echo 'Position: ' . $i;
  echo $row;

  $i++;
}//while

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.