here i have rc.RelatedCatagory like this (Flex Printing, Offset Printers, Digital Printers, Id Card Printers, Graphic Designers,News Papers)
if i get this ($subcatagory = $_GET['subcatagory'];) from first page value as (Flex Printing), then i want to display only (Flex Printing ) companies. how to match with that value one by one.
3.png is my main table
2.png is my main category
1.png in my frontend design, here i choosed (News Papers) but its showing maincategory wise data. so how can i change this query to subcategory wise.
$maincateg = $_GET['maincateg'];
$maincatid = $_GET['maincatid'];
$subcatagory = $_GET['subcatagory'];
$subcatid = $_GET['subcatid'];
$catagory=$_GET['catagory'];
$sql = mysql_query("select DISTINCT s.Companyname,s.id,s.LogoImage,s.LogoPath,s.Url,ck.MainCatagory,c.city,st.state,sub.Subcatagory,sub.MainCatid,p.priority,rc.RelatedCatagory from spa s
left join relatedcatagories rc on rc.spaid=s.id
left join catagorykeywords ck on ck.id=rc.mainCatagoryid
left join subcatagorykeywords sub on sub.id=rc.RelatedCatagory
left join city_place cp on cp.spaid=s.id
left join cities c on c.city_id=cp.city_id
left join states st on st.state_id=c.state_id
left join priority p on p.company_id=s.id
WHERE s.Publish=1 AND rc.mainCatagoryid='$maincatid' AND ck.MainCatagory='$maincateg' OR rc.RelatedCatagory='$subcatagory' GROUP BY s.Companyname ORDER BY p.priority DESC ,s.id DESC LIMIT $start,$limit");