Peggy Posted January 19, 2010 Share Posted January 19, 2010 I'm trying to search more than one field of only one table of a data base. I've tried a lot of different variations but none of them seem to work. The first code below will work for searching only one field. $query = "SELECT * from products WHERE fulldescr like \"%$trimmed%\" order by product ASC"; -------------------------------------------------------------------------------------------------------------- Here are some of the variations that didn't work for searching multiple fields $query = "SELECT fulldescr, product, descr, keywords FROM products WHERE fulldescr LIKE '\"%$trimmed%\"' OR product LIKE '\"%$trimmed%\"' OR descr LIKE '\"%$trimmed%\"' OR keywords LIKE '\"%$trimmed%\"' order by product ASC"; $query = "SELECT fulldescr, product, descr, keywords FROM products MATCH (fulldescr, product, descr, keywords) AGAINST (\"%$trimmed%\")"; //---------------------------------------------------------------------- I Really appreciate any help!! Quote Link to comment Share on other sites More sharing options...
schilly Posted January 20, 2010 Share Posted January 20, 2010 It looks like your search query is double quoted: '\"$trimmed\"' Try $query = "SELECT fulldescr, product, descr, keywords FROM products WHERE fulldescr LIKE '%$trimmed%' OR product LIKE '%$trimmed%' OR descr LIKE '%$trimmed%' OR keywords LIKE '%$trimmed%' order by product ASC"; Also make sure you output the mysql error which should help you as well. Quote Link to comment Share on other sites More sharing options...
Peggy Posted January 20, 2010 Author Share Posted January 20, 2010 :) Thank You!!!! I knew it had to be a simple answer. I just hadn't figured it out. This is actually the code I ended up using. $query = "SELECT * from products WHERE fulldescr like \"%$trimmed%\" OR product like \"%$trimmed%\" OR descr like \"%$trimmed%\" OR keywords like \"%$trimmed%\" order by product ASC"; Thanks Again!!!! Quote Link to comment Share on other sites More sharing options...
pbucc Posted May 11, 2010 Share Posted May 11, 2010 so did this work for you? i am working something similar. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.