Reputation: 135
i am trying to develop my website and need some support. so my web page searches for a product's information and return an appropriate result.It works perfectly fine when user search through a keyword or product title in search box and submit the query but now with the list of result obtained, i want a filter search where the user is able to filter their search result according to price, brand, category, etc.
i have two tables in the mysql database 1 : product_info with columns productid, title, description, brand, category, price 2: product_image productid,imageid,imagename,image
please help me on how about i should begin with the process. i have looked on net and their are multiple suggestions on which script to use but i want to work with the simplest approach since i am new to all this. you can suggest anything related to this topic.Thank you:)
just to let you know, for single search box i used the following code.
$query= "
SELECT *
FROM `product_info`
WHERE `title` LIKE '% ".$search_name." %'
OR `title` LIKE '% ".$search_name."'
OR `title` LIKE '".$search_name." %'
OR `title` = '".$search_name."'";
$query_run=mysql_query($query);
if(mysql_num_rows($query_run)>=1)
{
echo'Showing '.mysql_num_rows($query_run).' results for items with "'.$search_name.'" in the title:';
//the result is displayed in the table format.
}
Upvotes: 1
Views: 1899
Reputation: 1071
The answer is that you don't use php for this. The whole idea of having a database is that you run queries against it in order to select data from it based on criteria. So you build a suitable WHERE clause for your query which will pull only the rows that match the criteria requested by the user.
Upvotes: 5