Very new to coding. I have 2 tables, zips_usa which includes all properly formatted zips (zipcode, lat / lon / city / state etc) in the US, and table ageus which includes columns such as first name, last name, category, comments. It took 3 weeks to write the zipcode radius search but I got there, mainly due to answers I found on this site. Thanks.
I now need help dealing with the output. I think I need a join statement between the tables and cannot get my head around the logic. Any help would be appreciated.
sql statement for zip radius search runs error free. Input is performed by a html form.
$sql = "SELECT latitude, longitude FROM zips_usa WHERE zipcode = '$zipcode'";
Table ageus column details (where users post to)
id first_name last_name dog_type comments city state entered gender category zipcode
How do I join the two tables so I can select output that includes all info from table ageus that includes zip codes found within the X mile radius?
2
Answers
Thanks again to everyone who answered. Using Misunderstood's suggestions to populate the fields, I was able to get the script fully working by using the "Populating a table from query results (mysql)" thread, from 13 years ago, amending the details accordingly to mysqli. I've only been coding since I retired a few months ago. This is a fantastic site for learning all this new stuff. More importantly, we now have a working dog / animal rescue site YAY.
All you need is a table with a zipcode, lat, lng, a radius to find every record in the table that is within that radius, and a list of the lat and lng for each zipcode.
I made a "ziplocation" table.
The use the results to populate the table with lat and lng in addition to the zipcode.
The best approach, IMHO, is to use the list of zipcode lat and lng to put populate the table’s lat and long.
A table of zips with lat and lang is easy to find.
Here is the query:
I copied the above sql from a demo app I did for a client in Ft. Lauderdale wanting an dating site.
The user enters their zipcode and a radius and it shows the available girls within that radius.
The number at the bottom of the page is the number of seconds it took to generate the HTML.
Dating app where only Girls within a zipcode radius are shown