mysql - Using the like Clause with a variable in PHP -


i have query dynamically constructed variables. of conditions have statement.

my code is:

$where .= " , name=" . "'" . $name . "'"; 

i use:

$where .= " , name "%'.$name.'%"; 

but unsure how structure it.

thanks

it's looks on right track. this...

$where .= " , name '%" . $name . "%'"; 

but, when adding fields string, find easier use php sprintf() function. example:

$where = sprintf("select * users name '%s' , status='%s'",     "%" . mysql_real_escape_string($name) . "%",     "active" ); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -