www.webdeveloper.com
Results 1 to 3 of 3

Thread: filter results by location

  1. #1
    Join Date
    Nov 2008
    Location
    Niagara Falls, Canada
    Posts
    350

    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?

    Thanks

  2. #2
    Join Date
    Sep 2008
    Posts
    95
    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:

    Code:
    $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'");
    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.

    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.

  3. #3
    Join Date
    Nov 2008
    Location
    Niagara Falls, Canada
    Posts
    350
    Thanks for the reply. I was looking for a pre-existing script that I could use / modify.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles