I have a table with 3 columns:
zip
City
State
Most cities have multiple zip codes. I'd like to create a dropdown list with one city per area.
Say a city has zip codes 10002, 10003 ... 10012. I would like to only list this city once.
Now, I've tried something like this (I use db class so bare with me):
$selectCity = $db->get_results("SELECT zip, city, state FROM t1";
and draw list
echo '<select name=cityList>';
foreach ($selectCity as $city) {
echo '<option value="">'.$city->city.' -- '.$city->state;
echo '</select>';
I was thinking of using DISTINCT but am not sure how to use it here, since there could be same name city in different state...
Also I'd like to shorten my list by skipping cities with, say only 3 zip codes.
Worked myself into the woods at the moment...