Developing a custom store locator map: Create a PHP file to connect to the database

This is the third post in my series on creating your own custom store locator map using Google maps, PHP, and XML. In this post we are going to create a simple PHP file which will be used to connect the store locator in our website to the database of store locations.

Select and copy this code:


Past the code into a blank text file. Simply replace the values in the code with the correct values to your database.

Save the file as databaseconnect.php or whatever you want to call it (as long as it has the .php extension). Upload the file to your server.

The next step in creating our own store locator is to create the XML file which will process the calls for store locations in a browser.

Here are links to all of the posts in this series on how to create your own store locator map:


Create a spreadsheet of your store locations

Create and populate the MySQL table

Create a PHP file which will be used to connect to the database

Create a PHP file which will output the XML file results of a search

Create the HTML page which contains the store locator map


 And here are some hints and tips to help create and customize your store locator map:

Using your own custom markers for the locations in place of Google’s default markers

How to prevent the map from zooming in to close on a single location