Jump to content

Assigning Ranks To Rows (MySQL/PHP) PLEASE HELP


triphis

Recommended Posts

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 :)

Link to comment
Share on other sites

  • 2 weeks later...

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.

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.