tags:

views:

22

answers:

2

Hi,

I am trying to do the following:

$search_query = "SELECT spec, title, quantity, location_to, location_from
                           FROM sm12761.assignments WHERE title = ? LIMIT 0,1 ";

But change it to WHERE title LIKE '&something%'

How would I do this ?

If some one could show me a refactored version of the query that would be great.

+1  A: 

append a % to your input string when calling mysqli_stmt_bind_param()

Dennis Haarbrink
But that won't change an `=` to a `LIKE`...
ircmaxell
You can't do that without altering the query.
Dennis Haarbrink
A: 

Prepared statements are being precompiled on MySQL's side, so you need to change the query structure, to be able to use LIKE.

$search_query = "SELECT spec, title, quantity, location_to, location_from
                       FROM sm12761.assignments WHERE title LIKE ? LIMIT 0,1 ";
Mchl
how would I add in a % though so its finding a wildcard
Oliver Bayes-Shelton
Like Dennis Haarbrink said above, you need to add it to your search string before you bind it to parameter.
Mchl
Sorry just realised what he said.
Oliver Bayes-Shelton