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
Post a Comment