I have constructed a list here:
http://www.jersey.uk8ball.net/rankings.php
I have no problem sorting on any of the columns that feature in the MySQL table, however, I want to sort on the last column that is calculated as follows:
Code: Select all
$totalprizes = $p_proam + $p_open + $p_lsingles + $p_lchamps + $p_oneframe + $p_cabbages + $p_junior + $p_12;This is the full page code I have constructed so far:
Code: Select all
<?PHP
include("header.php");
include("sidebar.php");
$user="???";
$host="???";
$password="???";
$database="???";
$connection = mysql_connect($host,$user,$password)
or die ("Could not connect to the database");
$db = mysql_select_db($database,$connection)
or die ("Could not select the database");
$query = "SELECT * FROM players";
$result = mysql_query($query)
or die ("Could not execute query");
$rank=1;
echo "<table cellspacing=3><tr><td><h3>Player Rankings</h3>";
echo "<p>Click on a players name to see further details on each player. Click on an event header to sort by that column</p>";
echo "<table border=1 cellpadding=2><td width=20><b><a href=rankings.php>Rank</a></b></td><td width=200><b><a href=rankings.php?sortt=name>Player</a></td>";
echo "<td width=50><b><a href=rankings.php?sortt=status>Status</a></b></td><td width=50 align=right><b><a href=rankings.php?sortt=proam>Pro Am</a></b></td>";
echo "<td width=50 align=right><b><a href=rankings.php?sortt=open>Open</a></b></td>";
echo "<td width=50 align=right><b><a href=rankings.php?sortt=ls>Ladies Singles</a></b></td>";
echo "<td width=50 align=right><b><a href=rankings.php?sortt=lc>Ladies Champs</a></b></td>";
echo "<td width=50 align=right><b><a href=rankings.php?sortt=one>One Frame</a></b></td>";
echo "<td width=50 align=right><b><a href=rankings.php?sortt=cab>Cabbages</a></b></td>";
echo "<td width=50 align=right><b><a href=rankings.php?sortt=junior>Juniors</a></b></td>";
echo "<td width=50 align=right><b><a href=rankings.php?sortt=125>£125 a man</a></b></td>";
echo "<td width=50 align=right><b>Total</b></td>";
while ($row = mysql_fetch_array($result))
{
extract($row);
$totalprizes = $p_proam + $p_open + $p_lsingles + $p_lchamps + $p_oneframe + $p_cabbages + $p_junior + $p_12;
echo "<tr><td width=20 align=center>$rank</td>
<td width=200><a href=players.php?p_look=".$player_id.">".$player_name."</a></td>\n
<td width=50>$status</td>\n
<td width=50 align=right>$p_proam</td>\n
<td width=50 align=right>$p_open</td>\n
<td width=50 align=right>$p_lsingles</td>\n
<td width=50 align=right>$p_lchamps</td>\n
<td width=50 align=right>$p_oneframe</td>\n
<td width=50 align=right>$p_cabbages</td>\n
<td width=50 align=right>$p_junior</td>\n
<td width=50 align=right>$p_125</td>\n
<td width=50 align=right>$totalprizes</td>\n";
$rank = $rank + 1;
}
echo "</table></td></tr></table>";
include("footer.php");
?>Pretty please, can anyone put me out of my misery?? :(
feyd | use post formatting tags