Hello,
I have a page that is querying a MySQL database for a list of courses available in a given city.
The query is based on CITY NAME.
Here is the WHERE statement:
WHERE
locations.locationcity = '$locationcity' AND
scheduledcourses.coursedate > CURDATE()";
Our needs have changed and I now need to do a search based on zip code. We want all classes to come up within 100 miles of the City zip code.
I have tweaked a code which returns me all zip codes within 100 miles of the city zip code. This part works.
The problem is that I cannot figure out how to get the results into the query.
Example, I can echo the results of my zip code radius search
Which looks like this
ok that seems to be the right track. The issue I am having is that I dont know how to build the array from my database.
I need to find a way to construct the array from this:
As you are showing very little code, we have to guess exactly what it is you are after.
This loop you have instigated extracts the zips into a var called $zip.
// here is the first loop
foreach ($location1->getZipsInRange(0, 200) as $miles => $zip) {
$miles = round($miles, 1);
// now you are doing a second loop, nested in the first
foreach ($zip) {
echo "$zip"; // this quoting is redundant
}
} // I think you must then end the first loop
Now, are you doing a db query for each of the first loops, so the sql query is being executed several times?
OR
Are you building up multiple zip variables for one single sql query?
Apologies for not showing the rest of the code. I will post,
but basically the issue IM having is getting the list of zips into an array then using the array in the query. I will post some more when i get home