Skip to main content
Sara_Reese
Inspiring
Dec 31, 2012 1:49 PM UTC
Answered

Advanced Search Results PHP

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 is closed to new replies. Start a new post to keep the conversation going.
bregentCorrect answer
Participating Frequently
Jan 1, 2013 12:20 AM UTC

>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

3 replies

bregentCorrect answer
Participating Frequently
Jan 1, 2013 12:20 AM UTC

>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

Translate
Rob Hecker2
Legend
Jan 1, 2013 2:13 PM UTC

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

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

Translate