Skip to main content
Sara_Reese
Inspiring
December 31, 2012
Answered

Advanced Search Results PHP

  • December 31, 2012
  • 1 reply
  • 1318 views

Hello, I am designing my first Dynamic Website in PHP and WAMP and have so far managed to create a working Search Element on my website (search for 20mm on www.reese-test.co.uk )

It shows a linkable pic in "column 1" and Description in "column 2".

What I would ideally like though is to seperate the code and description columns (as shown below - pic 1), the problem is the search only works by finding the content in the description column, I have tried all different things in the "Advanced" tab to Filter by "Code" and "Description" but it is still only filtering by "Description" only.

My question is, does anyone have any simple instructions to get it to filter for both columns. In the "Simple" panel I can only select one option to filter!!!

thankyou for your help!

This topic has been closed for replies.
Correct answer bregent

>I have tried all different things in the "Advanced" tab to Filter by "Code" and "Description"

To write SQL queries you need to understand Boolean logic. You can't use AND  because that would mean that both conditions would need to be true. You want results if either condition is true, so use OR.

Select *

FROM productlist

WHERE description LIKE %colname%

OR

code LIKE %colname%

ORDER BY code ASC

1 reply

bregentCorrect answer
Participating Frequently
January 1, 2013

>I have tried all different things in the "Advanced" tab to Filter by "Code" and "Description"

To write SQL queries you need to understand Boolean logic. You can't use AND  because that would mean that both conditions would need to be true. You want results if either condition is true, so use OR.

Select *

FROM productlist

WHERE description LIKE %colname%

OR

code LIKE %colname%

ORDER BY code ASC

Rob Hecker2
Legend
January 1, 2013

. . .also, LIKE is a rinkydink search method. Better to use MATCH. . .AGAINST.

http://dev.mysql.com/doc/refman/5.5/en/fulltext-search.html