I'm chugging along on my project, but i've hit a bit of a roadblock. I have a player database for a baseball league and on each team's page i'm trying to output a table of the team record holders for various stats. I've made 2 arrays that hold the category text for the first column and one for the corresponding column names i'll be searching (in the same order as the category array). I post the team's name from a form and it's stored as $data. I'm finding that the results I'm getting are not the correct values if the table had been sorted correctly with the DESC option. Help please!
$category = array("Games Played","Batting Average","At Bats","Hits","Doubles","Triples","Home Runs","Walks","Strikeouts","Stolen Bases","Caught Stealing","Runs Scored","RBI's","Slugging Percentage","On Base Percentage");
$column = array("g","avg","ab","h","doub","trip","hr","bb","k","sb","cs","r","rbi","slg","obp");
$query = "SELECT * FROM hitting WHERE team='" . $POST['data'] . "' ORDER BY '" . $POST['string'] . "' DESC";
$sort = mysql_query($query, $connection) or exit(mysql_error());
print "<center><table border=\"1\">";
print "<tr bgcolor=\"#0000A0\"><th colspan=\"18\"><font color=\"#FFFFFF\">Individual Single Season Records</font></th></tr>";
print "<tr>
<th><font size=\"-1\" color=\"#FF0000\"><b>Category</b></font></th>
<th><font size=\"-1\" color=\"#FF0000\"><b>Leader</b></font></th>
<th><font size=\"-1\" color=\"#FF0000\"><b>Record</b></font></th>
<th><font size=\"-1\" color=\"#FF0000\"><b>Year</b></font></th>
</tr>";
for ($x=0; $x<15; $x++)
{
$string = $column[$x];
$row = mysql_fetch_assoc($sort);
print "<tr>";
print "<td><center><font size=\"-1\">" . $category[$x] . "</font></center></td>";
print "<td><center><font size=\"-1\">" . $row[firstname] . " " . $row[lastname] . "</font></center></td>";
print "<td><center><font size=\"-1\">" . $row[$string] . "</font></center></td>";
print "<td><center><font size=\"-1\">" . $row[year] . "</font></center></td>";
print "</tr>";
}
print "</table>";