我正在使用:
$ordem = "%".$_GET['ordem']."%";
$arr = [];
$stmt = $conn->prepare("SELECT texto,data_hora FROM logs WHERE texto LIKE ?");
$stmt->bind_param('s',$ordem);
$stmt->execute();
$ordem
变量正在接收包含在DB中但未找到的值...
出了什么问题?
由于
答案 0 :(得分:1)
尝试以下代码
$stmt = $conn->prepare("SELECT texto, data_hora FROM logs WHERE texto LIKE '%?%'");
$stmt->bind_param('s', $_GET['ordem']);
或尝试以下与您所做的相似
$param = "%{$_GET['ordem']}%";
$stmt = $db->prepare("SELECT texto, data_hora FROM logs WHERE texto LIKE ?");
$stmt->bind_param("s", $param);