Hi all,
I am trying to write a small league table for my poker club. Its a very simple table that shows the players name, nickname, how much he has paid in total, how many times he has come first second or third and how much he has won in total. Each of these is in a field of its own in the mysql table.
I wanted show a small seperate table that showed who is currently winning the most money, who has won the most etc etc.
I am not sure how to find the highest number for the field and use it in a variable so that it can list all the players with the same result.
eg - if there are 3 players who each have won 3 times i want to show all three of them in the list. obvioulsy after each game the numbers change so i wanted a way to find out what is the most wins so far and then list everyone who is equal to that.
I think I need to use a select statement to get the highest number but i dont know what to do with or where to put the command.
I think the select statement is
SELECT MAX(first) as "most wins"
I would be very grateful if anyone could point me in the right direction.
The code I am using to get the result on to the web is
//MOST WINS
$query = "SELECT * FROM mondays ORDER by first DESC LIMIT 1";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
while ($row = mysql_fetch_assoc ($result)) {
$id = $row['id'];
$fname = $row['fname'];
$lname = $row['lname'];
$nick = $row['nick'];
$won = $row['won'];
$first = $row['first'];
$second = $row['second'];
$third = $row['third'];
echo " <div class=\"most-div\">
<h3>Most Wins</h3>
<p>$fname <span class=\"nickname\">$nick</span> $lname with <span class=\"number\">$first</span></p>
</div>
";
}
This is how get one on the list but there is more than one with the same wins.
www.grap.co.uk/poker/ will show the tables online
Many thanks