You didnât state in what way it doesnât work.
However, the answer is probably - operator precedence. The query is ANDing the GROUP IN(1,2) term with the 1st LIKE term, then ORing that with the rest of the LIKE terms. If you want all the LIKE terms to ORed together, you need to add ( ) around the ORed terms.
Next, donât put external/unknown data directly into an sql query statement, Use a prepared query with a place-holder for each value, then supply the values when the query is executed.
Also, since you appear to be using pagination, you should be building the common part of the query, with any FROM, JOIN, WHERE, GROUP BY, and HAVING terms in a php variable,then use this common part of the query in both the COUNT() query and the data retrieval query.
And, since GROUP is a reserved word, either thatâs not the real column name or you should be getting a sql syntax error.
And, list out the columns you are selecting, instead of using *.