I amtrying to use Min and Order By on a query but get error. This form is selected by a previous form populated by a drop down box from mysql. It works by selecting an event(track event say 100m SM) and runs a query pulling all SM 100 results. I want to show only the best time of each athlete and order by the overall best (MIN) performance. Without Order BY and (MIN) works fine, but of little use as shows all athletes in an event and random order, not by best(fastest=min of perf)
Query works , but as i add MIN(perf) - to show only the best performance of each athlete it fails. ORDER BY does not function, a problem with the call up of events from the populated drop down list. Code as below:
$username = "xx";
$password = "xx";
$hostname = "localhost";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
$selected = mysql_select_db("sc010_indoor")
or die("Could not select first_test");
$result = mysql_query("SELECT athfnam,athsurnam,club,MIN(perf),date,meeting FROM out4 WHERE Event LIKE '%" ORDER BY perf . $_GET['Events'] . "%'" );
$num = mysql_num_rows ($result);
if ($num >0) {
echo "<p><big><b> There are $num athletes.</b></big></p>";
echo '<table align="center"
cellspacing="2" cellpadding="2">
<tr><td align="left"><b>athfname</b></td>
<td><b>athsurnam</b></td>
<td><b>club</b></td>
<td><b>perf</b></td>
<td><b>date</b></td>
<td><b>meeting</b></td>
</td></tr>
';
while ($row=mysql_fetch_array($result,MYSQL_NUM)) {
echo "<tr><td align=\"left\">" .stripslashes($row[0]) . "</td><td align=\"left\">$row[1]</td><td>$row[2]</td><td>$row[3]</td><td>$row[4]</td><td>$row[5]</td></tr>\n";
}
echo '</table>';
mysql_free_result ($result);
}else{
echo '<p> There are no records at the moment.</p>';
}
mysql_close();
Charles
p.s how do I get highlighting to show on posts ?