Hi all, this is my first post and was wondering if someone can help me :D
See I have a search field with a results.php and I want to have results from multiple fields.

<form id="form1" name="form1" method="get" action="results.php">
    <input type="text" name="findthis" id="findthis" />
    <input type="submit" name="button" id="button" value="Go" />

i can get only from one category with this code

$mysearch = $_GET['findthis'];
$mystuff = mysql_query("SELECT product_id, product_name, furnishings_thumb, furnishings_info, lighting_info,lighting_thumb FROM Products_tbl WHERE product_name LIKE '%".$mysearch."%' ORDER BY product_name ASC");

while($row=mysql_fetch_array($mystuff)) {
print "<tr><td><img src='images/thumbs/".$row['furnishings_thumb']."' /></td><td>".$row['product_name']."</td><td>".$row['furnishings_thumb']."</td><td>".$row['furnishings_type']."</td><td><a href='furnishings_details.php?product_id=".$row['product_id']."'>more...</a></td></tr>";

I want someone to search a product name and get results from either lighting or furnishing depending on what was searched, say couch or lamp.I am only allowed to get results with furnishings how would i be able to get results for the lightings and furnishings
thanks if anyone can help

8 Years
Discussion Span
Last Post by marcosjp

What you can do (as one of many possible solutions) is create two arrays each containing the product names valid for furnishing and lightings and then use a conditional structure to build the final SQL.

You can use the in_array function to check if a searched product name is present in each product name array.

This way you can have different queries according to the product being searched.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.