So basically, if you didn't understand the question, I have a dropdown menu with car brands (TABLE BRANDS), and when you select a certain option like "Volkswagen" it should display information about car models that are related to the brand "Volkswagen". The car models are in a table called CARS and for example when you select "Volkswagen", below it should display "Polo", "Golf" etc (every entry that is connected with the foreign key brand_id which is located in CARS). How can I make this happen ? Here's where I've got so far:
<?php
$sql = "SELECT brands.name, cars.id, cars.model, cars.mileage, cars.color FROM brands, cars WHERE brands.id = cars.brand_id ORDER BY cars.model DESC, brands.name;";
$result = $mysqli->query($sql);
$sql1 = "SELECT id, name FROM brands";
$result1 = $mysqli->query($sql1);
?>
<select>
<?php
while ($row = mysqli_fetch_array($result1))
{
echo '<option value="'. $row['id'] .'">'. $row['name'] .'</option>';
}
?>
</select>