I'm in need of a bit of help >_<. I have two tables:
The first table which populated with car manufacturers called list_vehicle_marks with the columns
id | value
The second table, populated with car models called list_vehicle_models and has the following columns;
id | value | mark_id
The column mark_id has the same value as id in the first table, in other words, Ford has the id no. 37 and all Ford models have the mark_id as 37 too.
How would I create two dynamic dropdown menus, where the second menu shows only the models based on the manufacturer selected in the first menu?
This is what I have done so far:
<?php
connection to host, db, blah blah
if ($db->connect_error) {
echo "Failed to connect to MySQL: (" . $db->connect_error . ") "
. $db->connect_error;
} else {
$sql = "SELECT value FROM list_vehicle_marks";
$result_db = $db->query($sql);
if (!$result_db) {
echo $db->error . ' Error perform query!';
} else {
echo '<select name="value">';
echo '<option value="">Select...</option>';
while ($row = $result_db->fetch_object()) {
echo '<option value="' . $row->value . '">';
echo $row->value;
echo '</option>';
}
echo '</select>';
}
}
$db->close();
?>