Jump to content

League table


keane89wolves

Recommended Posts

Hello..

 

i have got on my website like a prediction league that all my members are involved in.

 

I have also got a league table showing the top 15 people. I want it so if your not in the top 15 to be below the table showing what position your in.. so it would show the top 15.. then you.. maybe in 345th. How can i work out from the db query what position of the table that member is in though? I can get all the other details down, just not the actual league position

 

Thanks for help

keane

Link to comment
https://forums.phpfreaks.com/topic/128398-league-table/
Share on other sites

$pos = 0
$pred = mysql_query("SELECT * FROM members WHERE id > '0' ORDER BY pred_points DESC LIMIT 20");
  while($pred2 = mysql_fetch_array($pred)){
  
  $name = $pred2['name'];
  $points = $pred2['pred_points'];
  $pos = $pos + 1;
  
  if($name==$username) {
  
  echo'<tr bgcolor="#CCCCCC">
  	  <td>'.$userid.'</td> 
          <td>'.$name.'</td>
          <td>'.$points.'</td>
	  <td></td>
        </tr>';
  
  } else {
  
  echo'<tr>
  	  <td>'.$pos.'</td> 
          <td>'.$name.'</td>
          <td>'.$points.'</td>
	  <td></td>
        </tr>'; 

	}

	}
	echo '</table>';

 

Just the standard table, haven't got a clue with the other bit.

Link to comment
https://forums.phpfreaks.com/topic/128398-league-table/#findComment-665256
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.