filter results by location
Looking to add a list of Music Teachers to website that could be searched by someone looking for a teacher by specific options.....
Example: Search by postal code and by instrument taught, etc.
This way someone could search for the closest piano teacher to where they live for example.
Does anyone know of any scripts etc. that could help with this?
You might receive better answers if you could include more detail in your question (i.e. what information, code, etc. you already have).
If you have a database table set up...something with a column for each search criteria, for example, then you could use a simple SQL query to extract the rows containing the Teachers you need. For example:
BE SURE TO CLEAN YOUR VARIABLES (i.e. use htmlentities($instrument,ENT_QUOTES, 'utf-8') ) before using the variable in your SQL to prevent SQL injection attacks.
$instrument='drum';//or whatever valid input you received from the user's search
$postalCode='12345';//or whatever valid input you received from the user's search
mysql_query("SELECT `teachers`.* FROM `teachers` WHERE `instrument`='$instrument' AND `postalCode`='$postalCode'");
Alternately, you could select all teachers from the database or in an array and loop through the array extracting the information which meets the user's search criteria. While this approach is probably less likely to be a threat to your database, it is resource intensive.
Thanks for the reply. I was looking for a pre-existing script that I could use / modify.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)