Gebruik hiervoor gewoon ajax, wanneer een geselecteerde wijziging gegevens van de server haalt om andere geselecteerde te voeden.
<select class="select_one">
<?php /* render first select ?>
</select>
<select class="select_two"></select>
<script>
$(function() {
$('.select_one').change(function() {
var select = $('.select_two').empty();
$.get('script.php', {region: $(this).val()}, function(result) {
$.each(result, function(i, item) {
$('<option value="' + item.value + '">' + item.name + '</option>').
appendTo(select);
});
});
});
});
</script>
en jij script.php
zou JSON van db moeten retourneren:
if (isset($_GET['region'])) {
$sql = new mysqli('localhost','username','password','database');
$region = mysqli_real_escape_string($sql,$_GET['region']);
$query = "SELECT * FROM cities WHERE region = $region";
$ret = $sql->query($query);
$result = array();
while ($row = $ret->fetch_assoc()) {
$result[] = array(
'value' => $row['id'],
'name' => $row['city']
);
}
echo json_encode($result);
}