I have a php script that runs a query for an on-site search feature but it is returning too many results. It is pulling the information from a database. I know there is some way to limit the searches so that only one result per page is listed in the search results. I am using the "SELECT Distinct" code but don't know if it is functioning correctly. This is the actual query code: $query1 = "SELECT Distinct Title, items.PageName, items.Thumbnail, items.MemberOf, OptionCode, DropCode FROM (items LEFT JOIN Options ON items.PageName = Options.PageName) LEFT JOIN DropDown ON items.code = DropDown.Code WHERE ((items.Code like '%$search%' or OptionCode like '%$search%' or DropCode like '%$search%') and (items.MemberOf <> '' or items.PageName <> '')) and Discon_YN=0 and Sol_YN<>0"; Code (markup): Let me know if you need more than just this code. If anyone can help it would be greatly appreciated!
Theres quite a lot to say, so Id suggest looking for a tutorial : http://www.php-mysql-tutorial.com/php-mysql-paging.php is one I found, I dunno if it's very good or not, there's plenty about.
Come to think of it, it might be in the actual comparing of the database fields to the search term. What I would really like to do is limit the search results so they are more specific to what the user is searching for without bringing up every instance of the search term in various results of the same page. Hopefully this will help clarify: $query1 = "SELECT Distinct Title, items.PageName, items.Thumbnail, items.MemberOf, OptionCode, DropCode FROM (items LEFT JOIN Options ON items.PageName = Options.PageName) LEFT JOIN DropDown ON items.code = DropDown.Code WHERE ((items.Code like '%$search%' or OptionCode like '%$search%' or DropCode like '%$search%') and (items.MemberOf <> '' or items.PageName <> '')) and Discon_YN=0 and Sol_YN<>0"; } else //if($SearchType == "keyword_search" || $SearchType == "brand_search") { //ExtraWhere is to compensate for a single 3 character search. $ExtraWhere = ""; if(strlen($search) == 3) { $ExtraWhere = " or (CartDesc like '%".$search."%')"; } $query1 = "SELECT MATCH (Title,items.PageName) AGAINST ('$search')+MATCH (Hype.Hype,Headline,SubHead1,SubHead2,Hype.Feature1,Hype.Feature2,Hype.Feature3, Hype.Feature4,Hype.Feature5,Hype.Feature6,Hype.Feature7,Hype.Feature8,Hype.Feature9,Hype.Feature10) AGAINST ('$search')+ MATCH (Hype.Feature11,Hype.Feature12,Hype.Feature13,Hype.Feature14,Hype.Feature15,Feature16, Feature17,Feature18,Feature19,Feature20,Hype.Extra,Hype.PageTitle,Hype.PgDesc,Hype.Keywords) AGAINST ('$search') AS relev, Title, items.PageName, Hype.PgDesc, Hype.Feature1, Hype.Feature2, Hype.Feature3, Hype.Feature4, Hype.Feature5, Hype.Feature6, Hype.Feature7, Hype.Feature8, Hype.Feature9, Hype.Feature10, items.Thumbnail, items.MemberOf FROM items, Hype WHERE items.PageName = Hype.PageName AND Hype.SiteName='Sol Site' AND items.PageName<>'' and subcat<>'' and subcat is not null and discon_yn=0 and SOL_YN<>0 AND ((MATCH (Title,items.PageName) AGAINST ('$search') OR MATCH (Hype.Hype,Headline,SubHead1,SubHead2,Hype.Feature1,Hype.Feature2,Hype.Feature3, Hype.Feature4,Hype.Feature5,Hype.Feature6,Hype.Feature7,Hype.Feature8,Hype.Feature9,Hype.Feature10) AGAINST ('$search') OR MATCH (Hype.Feature11,Hype.Feature12,Hype.Feature13,Hype.Feature14,Hype.Feature15,Feature16, Feature17,Feature18,Feature19,Feature20,Hype.Extra,Hype.PageTitle,Hype.PgDesc,Hype.Keywords) AGAINST ('$search'))".$ExtraWhere.") order by relev desc"; } Code (markup):
I don't know if you are refering to the previous post but I am still confused on the filtering of my search results. Help?!