Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Filter a business directory database

  • 21-10-2012 03:37PM
    #1
    Registered Users, Registered Users 2 Posts: 173 ✭✭


    Hey, I am a student; my knowledge is limited.. so if this seems too simple apologies in advance..

    I am creating a business directory with the following headings which the user will see:

    Business Name
    Phone Number
    Street Address
    Town
    County
    Website

    Which displays on my page fine as per the screenshot below. (excuse the design - work to do on that!)

    What i want to do is to filter the database to show only results for a certain county. I want the user to be able to click on a county in the map which will result in the user viewing only business`s who are located in that county.

    I know how to create links on the image using the hotspot tool; thats not a problem.

    The problem is only showing results from a certain county.

    8108767095_450ac5f24e_b.jpg


    I have the database in phpmyadmin as follows:

    8095141501_86d1fc6523_b.jpg


    In dreamweaver I created a recordset to display the data using the following SQL Code (generated in Access)

    SELECT tblcarservicedirectory.businessid,
    tblcarservicedirectory.businessname,
    tblcarservicedirectory.businessphonenumber,
    tblcarservicedirectory.businessaddress,
    tblcarservicedirectory.businesswebsitehyperlink,
    tblcarservicedirectory.businesswebsitetext,
    otbltown.townname, 
    otblcounty.countyname
    FROM otbltown INNER JOIN (otblcounty INNER JOIN tblcarservicedirectory ON
    otblcounty.countyid = tblcarservicedirectory.businesscounty) ON
    otbltown.townid = tblcarservicedirectory.businesstown
    
    Could I create a recordset on a seperate page to show results from a certain county? for example Co.Carlow, which has an INT value of 3.

    What would i need to do to the SQL code above to achieve this?

    Alternatively I could link to within the recordset on the same page to direct the user to the section relevant to their county?

    Thanks for any tips or advice? :)


Comments

  • Registered Users, Registered Users 2 Posts: 7,544 ✭✭✭BrokenArrows


    Just add a WHERE condition at the end of your current SQL
    SELECT tblcarservicedirectory.businessid,
    tblcarservicedirectory.businessname,
    tblcarservicedirectory.businessphonenumber,
    tblcarservicedirectory.businessaddress,
    tblcarservicedirectory.businesswebsitehyperlink,
    tblcarservicedirectory.businesswebsitetext,
    otbltown.townname, 
    otblcounty.countyname
    FROM otbltown INNER JOIN (otblcounty INNER JOIN tblcarservicedirectory ON
    otblcounty.countyid = tblcarservicedirectory.businesscounty) ON
    otbltown.townid = tblcarservicedirectory.businesstown
    [B]WHERE otblcounty.countyname = 3[/B]
    
    
    
    


  • Registered Users, Registered Users 2 Posts: 173 ✭✭Not a person


    Just add a WHERE condition at the end of your current SQL
    SELECT tblcarservicedirectory.businessid,
    tblcarservicedirectory.businessname,
    tblcarservicedirectory.businessphonenumber,
    tblcarservicedirectory.businessaddress,
    tblcarservicedirectory.businesswebsitehyperlink,
    tblcarservicedirectory.businesswebsitetext,
    otbltown.townname, 
    otblcounty.countyname
    FROM otbltown INNER JOIN (otblcounty INNER JOIN tblcarservicedirectory ON
    otblcounty.countyid = tblcarservicedirectory.businesscounty) ON
    otbltown.townid = tblcarservicedirectory.businesstown
    [B]WHERE otblcounty.countyname = 3[/B]
    
    
    
    

    Thanks,

    It worked with adding
    WHERE otblcounty.countyid = 3
    

    Much appreciated!


Advertisement