Brand new to the forum, and have only been working with HTML, PHP, & MySQL for about 3 months.
I've run into an issue I can't seem to figure out how to work around. I want to have two select boxes, that are dependent on one another.
For Example:
First box lists types of games:
RPG
LARP
Board Game
Miniatures
CCG
The second box displays game names of the type selected above.
I have a MySQL table setup for the second box. To be honest I kinda already have it working... with one small but MAJOR glitch.
I select the first box and the page submits using onchange='this.form.submit()'. When the page reloads the first select box reverts back to it's default setting, but the second box does correctly filter & show the content based on the selection that was made in the first box.
My Question:
How do I set this up so that the first box displays the user selected setting while also passing the $_POST information to the second box?
My Code:
<table>
<tr>
<td width=50%>
Game Type:
</td>
<td width=50%>
<form name='game_type' action='event_submit.php' method='post'>
<select name='game_type' align=center onchange='this.form.submit()' style="width:150px;margin:5px 0 5px 0;">
<option value=''>Chose a Game Type</option>
<option value='RPG'>RPG</option>
<option value='LARP'>LARP</option>
<option value='Board Game'>Board Game</option>
<option value='CCG'>Collectable Cards & Games</option>
<option value='Miniatures'>Miniatures</option>
</select>
</form>
</td>
</tr>
<tr>
<td width=50%>
Game System:
</td>
<td width=50%>
<?php
$game_type = $_POST['game_type'];
echo "$game_type";
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("DrowCon", $con);
$result = mysql_query("SELECT * FROM Games WHERE Type='$game_type' ORDER BY System ASC");
echo "<form name='game_system' action='event_submit_form.php' method='post'>";
echo "<select name='game_system' align=center style='width:150px;margin:5px 0 5px 0;'>";
echo "<option value=''>Chose a Game System</option>";
while($row_game = mysql_fetch_array($result))
{
echo "<option value=''>".$row_game['System']."</option>";
}
echo "</form>";
mysql_close($con);
?>
</td>
</tr>
</table>