I have the following code:
if (empty($zips)) echo 'Error: '.$z->last_error;
else {
foreach ($zips as $key => $value) {
echo "Zip code <b>$key</b> is <b>$value</b> miles away from <b>93001</b>.<br>";
$getcity = "Select city from zip_code where zip_code = '$key'";
$resultgetcity = mysql_query($getcity);
$resultsetgetcity = mysql_fetch_array($resultgetcity);
}
I want to add every result to an array because I need to manipulate it later. I tried to do something like this:
if (empty($zips)) echo 'Error: '.$z->last_error;
else {
foreach ($zips as $key => $value) {
echo "Zip code <b>$key</b> is <b>$value</b> miles away from <b>93001</b>.<br>";
$getcity = "Select city from zip_code where zip_code = '$key'";
$resultgetcity = mysql_query($getcity);
$resultsetgetcity = mysql_fetch_array($resultgetcity);
$orgcity = "Bigcity";
$cities = array($orgcity);
array_push($cities, $resultsetgetcity[0]);
}
I was hoping that I could run a while loop or a for loop and loop through all of the contents of $cities but I can't seem to add every result to the array from the foreach statement. Can anyone help me?
Thanks in advance.