paulman888888 Posted December 10, 2008 Share Posted December 10, 2008 hi people; Its a simple question // Build SQL Query $query = "SELECT * FROM "; $query.=$search_table;// The Table to Search $query.=" WHERE "; $query.=$query_where;//The Column to Search $query.=" LIKE \"%$trimmed%\" ";// $trimmed is my Search content $query.=" ORDER BY "; $query.=$order_by; $numresults=mysql_query($query); That's my code but i would like to search in more columns. So here's my question. How do i make my code search in more columns? I thought of something like the below but not sure if there even the correct syntax. //The part i think i need to add $query_where=$column1.' OR ' $column2;// Am i nearly right? // Build SQL Query $query = "SELECT * FROM "; $query.=$search_table;// The Table to Search $query.=" WHERE "; $query.=$query_where;//The Column to Search $query.=" LIKE \"%$trimmed%\" ";// $trimmed is my Search content $query.=" ORDER BY "; $query.=$order_by; $numresults=mysql_query($query); Thankyou All Paul Quote Link to comment Share on other sites More sharing options...
gevans Posted December 10, 2008 Share Posted December 10, 2008 close, see if this makes sense instead of; $query_where=$column1.' OR ' $column2;/ try $query_where=$column1.'='something' OR ' $column2.'=something';/ Quote Link to comment Share on other sites More sharing options...
msinternet Posted December 10, 2008 Share Posted December 10, 2008 Hi, I think you want the query to be SELECT * FROM `search_table` WHERE `column1`,`column2` LIKE "%$trimmed%" ORDER BY etc. Note the comma Martin 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.