people!
I have this query which gets its WHERE
arguments from $_POST
. The thing is I want to get both the comparison values dynamically, without creating a query for each value. What I have now is:
$what = $mysqli->real_escape_string($_POST['what']);
........
$query = "SELECT * FROM list WHERE ";
$query .= $what . " = ? LIMIT 0,10";
........
$stmt->bind_param('s', $what);
My first question: How safe is this in practice? Is there another, better way I can manage the same thing, since i cannot bind both parameters?
Second problem I have is: I want to change the = ?
to LIKE %?%
, but i can't get it working. I tried using CONCAT('%', ?, '%')
(bad, I know) , but it's still not working.
Basically what i want to achieve in the end is: WHERE ? LIKE %?%
. Is it possible? Can you help me a bit with this?
Cheers, Alex