Forum Moderators: coopster
$find_zips="SELECT * FROM zipcodes WHERE longitude > '$north' AND longitude < '$south' AND latitude > '$west' AND latitude < '$east'";
$find_all_zips = mysql_query($find_zips);
if (!$find_all_zips) {
die('<p>error retrieving zipcodes<br>' . 'Error: ' . mysql_error() . '</p>');
}
$all_zips = mysql_fetch_array($find_all_zips);
echo $all_zips['0'];
echo $all_zips['1'];
echo $all_zips['2'];
echo $all_zips['3'];
echo $all_zips['4'];
that is my closest guess as to how to convert the results of $find_all_zips into an array. However, this is evidently how the proper way of going about things. How would i convert those results into an array?
//Get number of records
$N=mysql_num_rows($find_all_zips);
//iterate N times
for($i=0; $i<$N; $i++) {
$row=mysql_fetch_assoc($find_all_zips);
$all_zips[]=$row['zip'];
}
Now $all_zips will be an array with all of the zipcodes (I assuming here your field name is zip).
while ($all_zips = mysql_fetch_array($find_all_zips)) {
foreach ($all_zips as $col_name => $col_data) {
echo $col_name . ' = ' . $col_data . '<br />';
}
echo '<br />';
}
You probably don't want all of the columns output, so instead of the 'foreach' loop you could replace it with.
echo $all_zips['desired_SQL_field_name'] . '<br />';
include("database.php");
mysql_select_db($db, $con);
foreach ($all_zips as $col_name => $col_data) {
$col_data=sprintf("%05d",$col_data);
$find_users="SELECT * FROM musicians WHERE '$col_data'=zip";
$all_users=mysql_query($find_users);
if (!$all_users) {
die('<p>error retrieving latitude<br>' . 'Error: ' . mysql_error() . '</p>');
}
while ($result = mysql_fetch_array($all_users)) {
$newid = $result['ID'];
$newname = $result['username'];
$newlisting = $result['listing'];
$newgear = $result['gear'];
}
echo '<U><B><A HREF="userpage.php"><p align="justify"><font color="red">' . $newname . '</font><font color="black"></B></U><br /> ' . $newgear . '</A></font><hr><br />';
unset($newid);
unset($newname);
unset($newlisting);
unset($newgear);
}