PDA

View Full Version : Filter a Business Directory Database


Need Help 26
10-21-2012, 02:26 PM
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.

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.

http://farm9.staticflickr.com/8043/8108767095_450ac5f24e_b.jpg (http://www.flickr.com/photos/88745162@N02/8108767095/)


I have the database in phpmyadmin as follows:

http://farm9.staticflickr.com/8050/8095141501_86d1fc6523_b.jpg (http://www.flickr.com/photos/88745162@N02/8095141501/)


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? :)

edbr
10-22-2012, 01:14 AM
use a url link such as (to page country.php) country.php?country=3

then on the page collect the value
<?php
$country = 4_GET=['country'];
select * from
FROM otbltown INNER JOIN (otblcounty INNER JOIN tblcarservicedirectory ON
otblcounty.countyid = tblcarservicedirectory.businesscounty) ON
otbltown.townid = tblcarservicedirectory.businesstown

WHERE businesscounty =$country;

jmichae3
11-12-2012, 07:04 AM
the 4_get was a typo, it is actually $county = $_GET['county']; which will contain the value from the Irelandservicedepts.php?county=3

and country should be changed to county in a few places. you probably already cought it,but in case you didn't, this is what the code was supposed to be.

edbr
11-12-2012, 07:09 AM
:) whoops, good catch