| | |
Php search with multiple fields result ques?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Feb 2009
Posts: 4
Reputation:
Solved Threads: 0
Hi all, this is my first post and was wondering if someone can help me 
See I have a search field with a results.php and I want to have results from multiple fields.
i can get only from one category with this code
results.php:
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

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">
Search:
<label>
<input type="text" name="findthis" id="findthis" />
</label>
<label>
<input type="submit" name="button" id="button" value="Go" />
</label>
</form>i can get only from one category with this code
results.php:
<?php
require_once("connect.php");
$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
•
•
Join Date: Mar 2008
Posts: 42
Reputation:
Solved Threads: 0
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.
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.
Last edited by marcosjp; Feb 6th, 2009 at 7:42 pm.
![]() |
Other Threads in the PHP Forum
- Previous Thread: How can i check if http is present in img tag
- Next Thread: Passing ID from one page to another
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date development directory display download dynamic echo email error file files filter folder form forms function functions gc_maxlifetime google host href htaccess html image include insert integration ip java javascript joomla limit link login loop mail memmory memory menu mlm mod_rewrite multiple mysql navigation oop parse parsing paypal pdf php problem query radio random recursion regex remote script search server sessions sms snippet soap source space sql structure syntax system table thesishelp tutorial update upload url validation validator variable video web xml youtube





