Jump to content


Photo

Assigning Ranks To Rows (MySQL/PHP) PLEASE HELP


  • Please log in to reply
1 reply to this topic

#1 triphis

triphis
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 03 April 2003 - 02:33 AM

Okay, I am trying to creating a ranking list based on total number of points. I have my page set up, and I\'m trying to figure out how to make it say \"1st Place\", etc. Here is my page so far: http://members.lycos.co.uk/triphis/ and im TRYING to get it like this: http://neoguide.dcwd.biz/Pet.asp I asked the owner of that site, but obviously she replied with an ASP command (Counter)... so how do you do it in PHP? Thank you :)
Xac Attack

#2 wompus

wompus
  • Members
  • Pip
  • Newbie
  • 8 posts
  • LocationNY

Posted 11 April 2003 - 08:03 PM

Sort the results in descending order based on points.

$query = "ALTER TABLE tablename ORDER BY points DESC"; 

$result = mysql_query($query);

Then get the data like this

$query = "SELECT * FROM tablename"; 

$result = mysql_query($query); 

while($row = mysql_fetch_array($result)){

if($count=="") {$count=1;}

else {$count = $count+1;}



echo("This is ".$count." with ".$row[points]."<br>");

}

This should repeat for every entry in your table.
Free the West Memphis 3 http://wm3.org




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users