Alright, I'm not even sure if this is possible or not.
What I'd like to have a script do is this..
When you view a players profile, it shows you their rank compared to everybody else in every skill.
Such as on the players profile, say the player has the highest speed, and is second best in strength i'd like it show like this.
Speed - Rank 1
Strength - Rank 2
It seems like you'd have to sort a column in the database and echo out the position that they are in. Not exactly sure how to do this, or if possible.
Is there a mysqli function to do this, or am I out of luck?
Help With Rankings
Re: Help With Rankings
Leaves me in the same spot, how do I determine what speed_rank is when the player levels up.Oroton wrote:Just add a new column to the same table as where the speed and other skills lets say they are in chapter table
With names strength and speed then make new columns speed_rank and strength_rank and have the values stored there, very easy and possible... And just echo the data like you said
Anything is possible...
Re: Help With Rankings
Thanks for the help but that's not what I'm looking for.
What I'm looking for is how to find a players Rank in each skill, compared to every other player.
What I'm looking for is how to find a players Rank in each skill, compared to every other player.
Re: Help With Rankings
Sounds like you're looking for something like
Code: Select all
SELECT COUNT(id)+1 as rank FROM players WHERE skill>$playerSkillRe: Help With Rankings
How would I use this and echo the result?Winawer wrote:Sounds like you're looking for something likeCode: Select all
SELECT COUNT(id)+1 as rank FROM players WHERE skill>$playerSkill
This is what I have, and I get undefined index speed on the echo line.
<?php
$rank="SELECT COUNT(cid)+1 as rank FROM `characters` WHERE `speed`>'$profile3[speed]'";
$rank2=mysqli_query($db,$rank) or die (mysqli_error($db));
$rank3=mysqli_fetch_array($rank2);
echo "Speed: Rank " . $rank3['speed']. "<br>";
?>
Re: Help With Rankings
Use "rank" with $rank3 (not "speed"):MikeD wrote:How would I use this and echo the result?Winawer wrote:Sounds like you're looking for something likeCode: Select all
SELECT COUNT(id)+1 as rank FROM players WHERE skill>$playerSkill
This is what I have, and I get undefined index speed on the echo line.
<?php
$rank="SELECT COUNT(cid)+1 as rank FROM `characters` WHERE `speed`>'$profile3[speed]'";
$rank2=mysqli_query($db,$rank) or die (mysqli_error($db));
$rank3=mysqli_fetch_array($rank2);
echo "Speed: Rank " . $rank3['speed']. "<br>";
?>
Code: Select all
<?php
$rank="SELECT COUNT(cid)+1 as rank FROM `characters` WHERE `speed`>'$profile3[speed]'";
$rank2=mysqli_query($db,$rank) or die (mysqli_error($db));
$rank3=mysqli_fetch_array($rank2);
echo "Speed: Rank " . $rank3['rank']. "<br>";
?>
Re: Help With Rankings
Works like a charm, thanks alot!Winawer wrote:Use "rank" with $rank3 (not "speed"):MikeD wrote:How would I use this and echo the result?Winawer wrote:Sounds like you're looking for something likeCode: Select all
SELECT COUNT(id)+1 as rank FROM players WHERE skill>$playerSkill
This is what I have, and I get undefined index speed on the echo line.
<?php
$rank="SELECT COUNT(cid)+1 as rank FROM `characters` WHERE `speed`>'$profile3[speed]'";
$rank2=mysqli_query($db,$rank) or die (mysqli_error($db));
$rank3=mysqli_fetch_array($rank2);
echo "Speed: Rank " . $rank3['speed']. "<br>";
?>Code: Select all
<?php $rank="SELECT COUNT(cid)+1 as rank FROM `characters` WHERE `speed`>'$profile3[speed]'"; $rank2=mysqli_query($db,$rank) or die (mysqli_error($db)); $rank3=mysqli_fetch_array($rank2); echo "Speed: Rank " . $rank3['rank']. "<br>"; ?>