luisantonio Posted October 16, 2005 Share Posted October 16, 2005 Hi, I need a little help to make a multiple search with dreamweaver using PHP. My text box name in the search page is products since I had it working only searching the product name, but now I want to be able to search by product name and iten code(code) using only one textbox for the search. Below is the sql I am trying in dreamweaver for the multiple search function. SELECT * FROM products WHERE product = 'colname' OR code = 'colname2' ORDER BY product ASC Name = colname Default value= 1 Run time value = $HTTP_POST_VARS['product'] Name = colname2 Default value= 1 Run time value = $HTTP_POST_VARS['code'] Using OR it searches for product name(product) but using AND does not bring any results. Thanks. Quote Link to comment Share on other sites More sharing options...
rsnell Posted October 16, 2005 Share Posted October 16, 2005 Why would CODE = 'colname2' , aren't you expecting a number? The AND is picky and require an exact match. The OR will take either condition of PRODUCT or CODE matching. Quote Link to comment Share on other sites More sharing options...
luisantonio Posted October 17, 2005 Author Share Posted October 17, 2005 Why would CODE = 'colname2' , aren't you expecting a number? The AND is picky and require an exact match. The OR will take either condition of PRODUCT or CODE matching. 307208[/snapback] Dreamweaver asign the variable name as colname, don't know why, this was asign by default by dreamweaver. I asign colname2 for the code field fron the table, thinking it might work. Quote Link to comment Share on other sites More sharing options...
ThE_eNd Posted November 16, 2005 Share Posted November 16, 2005 And it should work. you can change colname and colname2 to whatever you want. And in the SQL Statement window you should have: SELECT * FROM products WHERE product = 'whatever' OR code = 'whateverelse' ORDER BY product ASC Name = whatever Default value= 1 Run time value = $HTTP_POST_VARS['product'] Name = whateverelse Default value= 1 Run time value = $HTTP_POST_VARS['code'] 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.