Im trying to do a select * from x where name LIKE y.I am very familiar with this code which is below.
SELECT * FROM ` arm` WHERE `u_fname` LIKE 'k%'
However, im trying to run this on a sever script and i am un sure where to put the “%” cause it results in errors. This is part of the sever code, this code works as it is with there ‘=’ but errors out when i use LIKE becuase im unsure how to use the “%” here
elseif(empty($_POST["f_name"]) && !empty($_POST["l_name"]))
{
$l_name=$_POST["l_name"];
$stmt = $this->db->prepare('SELECT id, image, l_name, f_name, status FROM table1 WHERE l_name =?');
$stmt->bind_param("s",$l_name);
$stmt->execute();
$stmt->bind_result($id,$image,$l_name,$f_name,$status);
I tried SELECT id, image, l_name, f_name, status FROM table1 WHERE l_name =?% and i have also tried putting $l_name=$_POST[“l_name%”]; but neither of them seem to work.
Thank you for help.
Your code isn’t using ‘LIKE’
Your code is: SELECT id, image, l_name, f_name, status FROM table1 WHERE l_name =?
Try
Or try