php - Location Search for Database -


i trying set mysql database website have list of various locations. possible set location-based search list? example, if searches "albany, ny, usa" there should results nearby "new york, ny" if database has no results albany.

i think neat way use latitude , longitude coordinates. however, if user enters in random city, there way acquire geographical coordinates of city website?

also, if user spells query wrong, there neat way still process information?

for first option use query in php following:

$sql = "select distinct * (`yourtable`) (`cityname` '%".$_post('search')."%')" 

this query search word typed in searchfield called 'search'

so example:

<input type="search" name="search"> 

for second part of question use bit more complex query searchterm.

so match first 2 characters example.

if want search nearby location use google geolocation api calculate distance between 2 rows in database.

https://developers.google.com/maps/documentation/business/geolocation/


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -