I get the form to populate with the lables; however, Im not sure how to code it so that when I press "go" the city id from the query passes to the page city.php.
I had the form submit to the same page, and request the id, however I got an error stating that header info had already been sent, so I would rather start from scratch so I can understand, vs just coping code and not knowing what is going on.
here is the current code on the page:
<?
$cities = getCities ($city_id);
?>
<form method="post" action="city_list.php">
<select name="city">
<?
foreach ($cities as $city){
echo '<option value="'.$city['city_id'] .'">'.$city['city_name'].'</option>';
}
?>
</select>
<input type="submit" name="submit" value="Go">
</form>
<?
function getCities ($city_id){
global $db;
$sql = "SELECT * FROM cities ORDER BY 'city_name' ASC";
return $db->queryAllRows($sql);
}
?>
It creates and populates the drop down form with the name of the city. now I need the city id to pass to another page called city.php.
Thanks to all for helping someone who is trying to learn.
🙂