LIKE operator


#1

I made a search for my website. However whenever I search for anything all of the items in my databases table are displayed instead of just the ones that are like the search term.

Here is my code:

$data = mysql_query(“SELECT * FROM food WHERE $_POST[field] LIKE ‘%$find%’”);

Any help would be greatly appreciated

Derek


#2

What’s the value of $find, just before/after running the query?


#3

It’s value of find was put input into a search box by the user.(user defined).
The value of field was also defined by the user next to the search box.


#4

Thanks for the idea of checking the output. it turned out that it wasn’t sending anything. I ended up having to change it from find to findit before it would work.


#5

This is the reason why we have a Debugging tutorial.