Jump to content

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

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.