Jump to content

[SOLVED] Selecting Top 50 High Point Scorers


papaface

Recommended Posts

Hey :)

I am trying to work out a way of selecting the top 50 high point scorers from my table. At the moment I have:

		$gettop = $ftcdb->get_col("SELECT * FROM `xperience_stats` ORDER BY `points_xperience` DESC LIMIT 0, 50");
	foreach ($gettop as $userid)
		{
		if ($userid == $this->getUserId())	$allowskip = true;
		}

 

It works absolutely fine. It selects the first 50 leaders and if their userid is one of the top 50 pulled from the table then $allowskip = true.

But what happens if the 50th and 51st user have the same score? User 50 would be $allowskip = true but 51 wouldn't.

Any idea how to get around that? With one query ideally.

 

Any help would be appreciated :)

 

Link to comment
Share on other sites

Generally speaking you would just order by other important stats. For example in a football league (soccer for any Americans) you are ranked first on points, then on goal difference then it might be away goals (depends on the tournament). Sometimes for display purposes teams are ranked on arbitrary stats such as alphabetical order.

 

If you don't want to do it this way then you could have the 'Top 50' being more than 50 individuals. You could simply use the query you already have, grab the `points_xperience` of the last player/person/team then do a further query to fetch all players that have the same amount of experience as them and add it to your result set (taking care not to add anybody twice obviously).

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.