I am trying to build a drop down element in html, and to add the values according to user pre-choice. Lets say I have table with one col is game type ans second is a name field. So if the user first drop down choice is basketball - so another drop down list is opened with all the basketball fields as options.
so I have my html file which has inside this php lines:
$game_type = $_POST['gameType'];
$con = mysql_connect("localhost", "root", "Jbtraining1");
if (!$con)
die('Could not connect: ' . mysql_error());
$db_selected = mysql_select_db("test_sport",$con);
$sql = ("SELECT * FROM fields WHERE game_type = '$game_type'");
$result = mysql_query($sql,$con);
while($row = mysql_fetch_array($result))
echo "<option value='".$row['field_name_en']."'>" . $row['field_name_en'] . "</option>";
?>
</select>
but this lines does not work. I think most of the lines work well cause if i chage this line:
$game_type = $_POST['gameType'];
to let say to this line -
$game_type = "basketball";
It does work just fine.
Thanks