%
is a placeholder for an arbitrary string.
So if you have something WHERE category LIKE '%keyword%'
this will return all categories that contain the word 'keyword'.
I guess what you are looking for is to find something that contains a given keyword, and the keyword is in your variable, so that would be WHERE category LIKE '%$variable%'
, with $variable
being the variable that holds the keyword. There are some issues of course with this, like the keyword cannot contain %
itself, otherwise it will have to be escaped and there is the issue of possible SQL injection, which should be approached by using prepared statements, but those issues seem a bit outside of the scope of the question.