Variable search help still needed - sorry :-(
| From: | Chris Payne | Date: | Sat, 19 Jan 2002 05:11:02 +0000 |
| Subject: | Variable search help still needed - sorry :-( | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-15985@lists.php.net to get a copy of this message | ||
Hi there,
I know this is probably a REALLY simple problem, but I can't get this to work. I need to get
it to cycle through each word and do a search, I used this as sent from Beau Lebens (Thank you) but
I can't get it to work. It works on 1 word querie but if I enter more than 1 it says
can't execute query, please help and tell me what i'm doing wrong :-)
Thank you so much.
Regards
Chris
www.planetoxygene.com
---------------------------------
$words = explode(" ", $test);
// create connection
$connection = mysql_connect("Localhost","!!!","!!!") or
die("Couldn't make a connection.");
// select database
$db = mysql_select_db("tas", $connection)
or die("Couldn't select database.");
$sql = "SELECT distinct description, email, url, country, category, type, rating from search6
WHERE ";
foreach ($words as $word) {
$sql .= "description LIKE '%word%'";
}
$sql .= "AND category = '$category' AND country = '$country' AND type =
'$type' ORDER BY description";
$sql = mysql_query($sql,$connection)
or die("Couldn't execute query.");