Heres the code that i am currently working with to achieve my dynamic select boxes. Its very rough 'n' ready at the moment. However it is erroring out and not retaining the value of the first select box, the one that call the groups.
For the purpose of just getting the thing to work i am only concerned with pulling out one set of team names.
Any help would be greatly appreciated.
<?
include("app_global.php");
//open the connection
$conn = mysql_connect("$glob_host", "$glob_user", "$glob_pass");
//pick the database to use
mysql_select_db($db_name, $conn);
//create the sql statement
$sql = "SELECT *
FROM dcass_groups
GROUP BY 'group'";
//execute the sql statement
$result = mysql_query($sql, $conn)or die(mysql_error());
//will go through each row in the result set and display data
while ($row = mysql_fetch_array($result)) {
//give a name to the fields
$team_id = $row['team_id'];
$group = $row['group'];
$team_name=$row['team_name'];
$group_options .="
<option value=\"$group\">$group</option>\n";
}
//to get the teams relevant to the group
//
if (isset($POST['finalsubmit']))
{
// PROCEED TO NEXT FORM
}
else
{
if (isset($POST['group']))
{
$result=mysql_query("select * FROM dcass_groups WHERE group=$_POST[group] ");
$teams='<select name="team1">';
while($row=mysql_fetch_array($result))
{
// RETURN DETAILS OF THE COUNTRY CHOSEN
$teams.='<option value="'.$row[team_id].'">'.$row[team_name].'</option>';
}
$teams.='</select>';
}
}
?>
<html>
<head>
<title>test</title>
<SCRIPT language="JavaScript">
function submitform()
{
document.form1.submit();
}
</SCRIPT>
</head>
<body>
<form name="form1" method="post" action="<?php echo $_SERVER[php_self];?>">
<select name="group" onChange="javascript:submitform();">
<?print $group_options;?>
</select>
<?php echo $teams;?>
<Br><br>
<input type="submit" name="finalsubmit" value="FINAL SUBMIT">
</form>
</body>
</html>