I have a form with a drop down box which is populated from
mysql, showing age groups and disciplines for athletics events.On selection I want to retreive the results ( in this case for an age group athletics results, and show how many athletes are say U15 doing 100m. At the moment all I get is the total number of athletes in the database- i.e on selection of an age, the foem handler is not picking up the age group.
Drop down box form is as follows:
<?php
$username = "vv";
$password = "vv";
$hostname = "localhost";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
$selected = mysql_select_db("sc010_indoor",$dbh)
or die("Could not select first_test");
?>
<form action="../athperformances2.php" method="get">
<SELECT NAME="Events">
<option value="xx" SELECTED>Select An Event</option>
<?
$result = mysql_query ("SELECT DISTINCT Event FROM out4 ORDER BY Event ");//populates drop down box-works fine
if ($row = mysql_fetch_array($result)) {
do {
print ("<OPTION VALUE=\"".$row["Event"]."\">");
print $row["Event"];
print ("</OPTION>");
} while($row = mysql_fetch_array($result));
} else {print "";}
?>
<input type="submit" value="search">
</select>
</form>
</body>
</html>
</p>
<p><font face="Arial, Helvetica, sans-serif"><a href="http://www.athletics-results.co.uk">HOME</a></font></p>
</div>
//this works fine and drop down is populated
The handel form is a follows:
<?php
$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 athsurnam, club FROM out4 where Event LIKE '%$xx%'");
$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>athsurnam</b></td>
<td align="left"><b>club</b>
</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></tr>\n";
}
echo '</table>';
mysql_free_result ($result);
}else{
echo '<p> There are no records at the moment.</p>';
}
mysql_close();
?>
</p>
<p><font face="Arial, Helvetica, sans-serif"><a href="http://www.athletics-results.co.uk">HOME</a></font></p>
</div>
//This only brings out all athletes in the database. Any help much appreciated
Charles