Hi
I am tring to populate a drop down by selecting another drop down.
The first drop dwon populates from eventdata table and i want the second drop down to populate from a race table. I have tried to find the row which contains the same event id as the first drop down box and then display the team id which has the same event id.
NOTE event id and race id will have the same data in them, bad naming on my part
<?php
include 'config.php';
include 'opendb.php';
$sql="SELECT event_Name FROM eventdata";
$result=mysql_query($sql);
$optionsevent="";
while ($row=mysql_fetch_array($result)) {
$event_Name=$row["event_Name"];
$event_Name=$row["event_Name"];
$optionsevent.="<OPTION VALUE=\"$event_Name\">".$event_Name;
}
function Generate(){
$sql="SELECT team_ID FROM race WHERE race_Name=$optionsevent";
$result=mysql_query($sql);
$optionsid="";
while ($row=mysql_fetch_array($result)) {
$team_ID=$row["team_ID"];
$team_ID=$row["team_ID"];
$optionsid.="<OPTION VALUE=\"$team_ID\">".$team_ID;
}
}
?>
<html>
<head>
<title>Rally Database - Results Entry Form</title><style type="text/css">
<!--
.style1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 24px;
}
body {
background-color: #CCCCCC;
}
-->
</style><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body>
<div align="center">
<p><strong><span class="style1">Results Entry Form</span></strong></p>
<p align="left">Please enter select the Race ID and then the Team ID. </p>
</div>
<form method="post" action="enterresultsinsert.php">
<label></label>
<p>
<label></label>
<label></label>
<label>Race ID
<select name="raceid">
<OPTION VALUE=0 onChange="Generate();" >Choose
<?=$optionsevent?>
</select>
</select>
</label>
<label>Team ID
<select name="teamid">
<OPTION VALUE=0>Choose
<?=$optionsid?>
</select>
</select>
</label>
</p>
<p>
<label>Stage 1 Time
<input name="stage1" type="text">
</label>
</p>
<p>
<label>Stage 2 Time
<input name="stage2" type="text">
</label>
</p>
<p>
<label>Stage 3 Time
<input name="stage3" type="text">
</label>
</p>
<label>Stage 4 Time
<input name="stage4" type="text">
</label>
<p>
<label>Stage 5 Time
<input name="stage5" type="text">
</label>
</p>
<p>
<label>Stage 6 Time
<input name="stage6" type="text">
</label>
</p>
<p>
<label>Stage 7 Time
<input name="stage7" type="text">
</label>
</p>
<p>
<label>Stage 8 Time
<input name="stage8" type="text">
</label>
</p>
<p>
<label>Total Time
<input name="total" type="text">
</label>
</p>
<p>
<label></label>
<label></label><label>
<input type="submit" name="Submit" value="Add Results">
</label>
</p>
</form>
</body>
</html>