I am totaly new to php and mysql, what i am trying to do is to let user can fill out a form to locate information based on a particular Province, the area inwhich service is provide(based on city) and the services that is provide, which is taken from check boxes. Is what I am even trying to do possible? here is the code for the query. Thanks for taking a look
$result = mysql_query(
"SELECT ag.AgencyID, ag.CompanyName, ag.Address, ag.StateOrProvince, ag.City, ag.PostalCode
FROM Agencies ag
WHERE ag.StateOrProvince ='$province'
AND ag.AgencyID IN ( SELECT aa.AgencyID
FROM AgencyAreas aa
INNER JOIN Areas ar ON (aa.AreaServedID = ar.AreaServedID)
WHERE a.Area LIKE '%$city')
AND ag.AgencyID IN ( SELECT as.AgencyID
FROM AgencyServices
WHERE ServiceID IN ($services))"
) or die("Invalid query: " . mysql_error() );
while ($myrow = mysql_fetch_array($result)) {
printf("Company name: %s <br />", $myrow['CompanyName']);
printf("Address: %s <br />", $myrow['Address']);
printf("City: %s <br />", $myrow['City']);
printf("Province: %s <br />", $myrow['StateOrProvince']);
printf("Postal Code: %s <br /><br /><br />", $myrow['PostalCode']);
}