Jump to content

A little help.


takn25

Recommended Posts

Hi, I was wondering is this possible in an easy way or do I have to come up with something else ^^.

 

I have a row called Rate and I am echoing something like this $query="SELECT * FROM clan ORDER BY rate DESC";

 

Which is going fine but now I want to know is there any way of echoing for example the highest rate in mysql is 1800 I want to echo 1 next to it showing this is coming first second is 1782 echo 2 next to it and so on. A bit difficult to explain for what I am trying to achieve mostly I want to echo 1,2,3,4,5 depending on  which rate has the highest number  The higher the rating the lower the number an example below I hope I made some sense.               

 

1 = 1800 

2 = 1782 

3 = 1600 

4 = 1500

 

Link to comment
https://forums.phpfreaks.com/topic/232285-a-little-help/
Share on other sites

In the event you have records with equal ratings you would need to track that

ie

1 = 1800

2 = 1735

2 = 1735

3 = 1500

ect

$query="SELECT * FROM clan ORDER BY rate DESC";
$result = mysql_query($query);
$i=0;
$last_rate = 0;
while($row = mysql_fetch_array($result)) {
$current_rate = $row['rate'];
if($current_rate != $last_rate) {
	$i++;
}
echo $i . " = " . $current_rate . "</br/>";
$last_rate = $current_rate;
}

Link to comment
https://forums.phpfreaks.com/topic/232285-a-little-help/#findComment-1195004
Share on other sites

Archived

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

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