However, I'm not familiar with sorting arrays, so within this snippet of code, how do I correct the function sortclubs1 so that it will sort as per the onClick selection? Some of the sorts may be ascending, some descending - I'm happy to have 2 sort functions defined for that purpose if necessary.
Code: Select all
function sortclubs1($order)
{
sort($foo[$order]);
}
echo "<h3 align=center>Clubs eligible for Euro Fantasy League</h3><br>";
/* Start a table, with column headers */
echo "\n<table border=1 bgcolor=444444 align=center>\n<tr>\n" .
"\n\t<th><a href="javascript:void(0)" onClick="sortclubs1('clubid')">Club ID</a></th>" .
"\n\t<th><a href="javascript:void(0)" onClick="sortclubs1('clubname')">Club</a></th>" .
"\n\t<th>Country</th>" .
"\n\t<th>Balls</th>" .
"\n\t<th>Def Pts</th>" ."\n\t<th><a href="javascript:void(0)" onClick="sortclubs1('defpts')">Def Pts</a></th>" .
"\n\t<th>Mid Pts</th>" .
"\n\t<th>Att Pts</th>" .
"\n\t<th>European Competition</th>" .
"\n</tr>";
foreach($squad as $foo)
{
echo
'<tr align=center><td>' .
$foo['clubid'] .
'</td><td>' .
'<a onmouseover="this.style.color=''red''" style="COLOR: yellow; TEXT-DECORATION: none"
onmouseout="this.style.color=''yellow''" href="club2.php?$clubid">' .
$foo['clubname'] .
'</a></td><td>' .
$foo['country_name'] .
'</td><td>' .
$foo['balls'] .
'</td><td>' .
$foo['defpts'] .
'</td><td>' .
$foo['midpts'] .
'</td><td>' .
$foo['attpts'] .
'</td><td>' .
$foo['competition'] .
'</td></tr>';
}
echo "\n</table>";