Login    Forum    Search    FAQ   Blog

Board index » Server Side Development » PHP




 Page 1 of 1 [ 5 posts ] 



Author Message
 Post subject: row position
 Post Posted: Thu Nov 12, 2009 11:06 am 
Offline

Joined: Sat Feb 21, 2009 2:24 pm
Posts: 30
hello all

i need something just like this

Code:
SELECT * FROM USERS ORDER BY GOLD DESC

it will return something like this

ID GOLD
3 555
1 400
2 100


how could i return da row place 4 ID 2 which does have 100 gold
Code:
ID 3 = place 1
ID 1 = place 2
how can i do that?
thank you


Top 
 Post subject: Re: row position
 Post Posted: Thu Nov 12, 2009 11:06 am 
Offline

Joined: Sat Feb 21, 2009 2:24 pm
Posts: 30
*bump*


Top 
 Post subject: Re: row position
 Post Posted: Thu Nov 12, 2009 11:06 am 
Offline

Joined: Sat Feb 21, 2009 11:06 am
Posts: 1794
generate a counter in PHP when u retrieve nd iterate through da
results. I aint sure if there is was way 2 do what you are asking, but
that was somethin you could google.


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

  $i++;
}//while


Top 
 Post subject: Re: row position
 Post Posted: Thu Nov 12, 2009 11:08 am 
Offline

Joined: Sat Feb 21, 2009 2:24 pm
Posts: 30
hank u


Top 
 Post subject: Re: row position
 Post Posted: Thu Nov 12, 2009 11:09 am 
Offline

Joined: Sat Feb 21, 2009 11:06 am
Posts: 1794
welcome


Top 
Display posts from previous:  Sort by  
 
 Page 1 of 1 [ 5 posts ] 




Board index » Server Side Development » PHP


Who is online

Users browsing this forum: No registered users and 1 guest

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron