I want to then allow the user to select one, hit submit or whatever, then below, (OR on another page, I don't mind) in a table, display the member first and last names (from member table), the race date, length (from race table) and the result (from result table).
At the moment I'm stuck as whatever u select nothing happens. I'm really confused about how to get the race name from the submitted drop down, do you use get or post or what?? Need a simple explanation of what ive done wrong, I KNOW its wrong but just cant figure out how to fix it, getting muddled
Thanks, and here's my code.. at the moment i have tried to post to the same page, but dont know how to check it, i know the line if (!isset($_GET['race'])) is incorrect but dont know what to put in its place (trying to see if user has selected a race name from the drop down).. thanks
Code: Select all
<?php
require_once('connection.php');
if (!isset($_GET['race'])) {
$res=mysql_query("select race_name from race");
if(mysql_num_rows($res)==0) {
echo "there is no data in table..";
}
else {
echo'<form action="bugger.php" method="post"><select name="categories">';
for($i=0;$i<mysql_num_rows($res);$i++) {
$row=mysql_fetch_assoc($res);
echo"<option>$row[race_name]</option>";
} // endof for
echo'</select><input type="submit" name="submit" value="race" />
<input type="hidden" name="submitted" value="TRUE" /></form>';
}
}
elseif ((isset($_GET['race']))) {
$getrace = $_GET['race'];
$res=mysql_query("select member.first_name,member.last_name,race.race_name,race.race_date,results.time from member,race,result WHERE race.race_name='".$getrace."'");
}
if(mysql_num_rows($res)==0) {
echo "there is no data in table..";
}
else {
//table header
echo'<table align="center" cellspacing="10" cellpadding="5">
<tr><td align="left"><b>First Name</b></td>
<td align="left"><b>Last Name</b></td>
<td align="left"><b>Race Name</b></td>
<td align="left"><b>Race Date</b></td>
<td align="left"><b>Race Time</b></td></tr>';
echo'</select>';
}
// fetch and print all the records
while($row = mysql_fetch_array($res,MYSQL_ASSOC)) {
echo'<tr><td align="left">'.$row['first_name'].'</td>
<td align="left">'.$row['last_name'].'</td>
<td align="left">'.$row['race_name'].'</td>
<td align="left">'.$row['race_date'].'</td>
<td align="left">'.$row['time'].'</td>
</tr>
';}echo'</table>';
?>called the page bugger.php btw, dont ask.
thanks