LIKE operator

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

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

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.

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.

This is the reason why we have a Debugging tutorial.

Sponsor our Newsletter | Privacy Policy | Terms of Service