我有一个代码,应该搜索所有数据,如表中的某些内容并打印每个数据,但我根本不工作
$words = explode(" ", $question);
foreach( $words as $each ) {
$sql = "SELECT * FROM $table WHERE question LIKE '%each%'";
$result = mysqli_query($conn, $sql);
while($row = mysqli_fetch_assoc($result)) {
printf(nl2br("%s\n"), $row['question']);
}
}
答案 0 :(得分:0)
您的查询中有拼写错误($
中缺少%each$
):
$sql = "SELECT * FROM $table WHERE question LIKE '%$each%'";