View Full Version : php search page

03-23-2009, 09:32 PM
need some advice on the best way to make a search page in php for a mysql database.

The database contains 3 columns with CSV's. The CSV's are all taken from a set list of about 20 different values.

I want users to be able to search for each row for different values using dropdowns or checkboxes.

For example, for row 1:
column a = "apples, pears, oranges"
column b = "red, black, green"
column c = "wood, stone, water"

so a user might want to find a row with columns a, b or c containing ALL of apples, oranges, red and stone **OR** ANY of apples, oranges, red and stone (preferably in the latter case sorted by the number of matched occurrences).

I'm familiar with the syntax for a basic search, but can't put together a query for this that does what I want it to.

Thank you in advance....

03-23-2009, 11:21 PM
The easy way is with the use of a FULLTEXT index. This is a MySQL index that gives you boolean search capabilities, so a search string of "+apples +pears +oranges" will only hit if all three words are found.

I would also nag you to normalize your data. Good article about it:


For more information on this type of index: