I am new to php so please bear with me. I am trying to make a php webpage in which it has multiple Select options. If I select an option from the select field, I would like another select field to change its values related to the select option. Here is my php code.
<div class="form-group">
<label for="Labels">Labels:</label>
<select class="form-control" name="labels" >
<?php
$q = "SELECT * FROM Labels ORDER BY LABELS_ID ASC";
$r = mysqli_query($dbc, $q);
while ($opt = mysqli_fetch_array($r)) {
echo "<option value='$opt[LABELS_ID]'>".$opt['LABELS']."</option>";
}
?>
</select>
</div>
<div class="form-group">
<label for="option_id">Options:</label>
<select class="form-control" name="option_id" id="option_id" >
<?php
$q = "SELECT * FROM OPTIONS ORDER BY OPTIONS ASC";
$r = mysqli_query($dbc, $q);
while ($opt = mysqli_fetch_array($r)) {
echo "<option value='$opt[OPTIONS_ID]'>".$opt['OPTIONS']."</option>";
}
?>
</select>
</div>
I am selecting the values from the database.
My Labels database is like this:
LABEL_ID LABEL
10001 Food
10002 Electronics
Or here is the image:
http://s7.postimg.org/npo87fi6j/Screen_Shot_2015_08_08_at_11_19_46_PM.png
My Options Database is like this:
OPTION_ID OPTION LABEL_ID
20001 Meat 10001
20002 Seafood 10001
20003 Chicken 10001
20004 Desktop 10002
20005 Laptop 10002
THANKS