PHP搜索未返回结果

时间:2018-10-29 16:39:11

标签: php search

我一直在尝试构建安全的搜索,但是没有返回任何结果。我刚收到“未找到结果!”。我的错误报告没有错误。

有什么想法吗?

<?php require_once("db/db.php"); ?>
<?php
ini_set('display_errors', 1); ini_set('log_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
?>


<?php
if (isset($_POST['search'])) {
    $stmt = $conn->prepare("SELECT * FROM pages WHERE title OR content LIKE ? ");
    $search = $_POST['search'];
    $stmt->bind_param("s",$search); 
    $stmt->execute();

    if($stmt->num_rows > 0 ) {
        while($rows = $stmt->fetch_assoc()) {

            echo $rows['title'];
        }
    }
    else {
        echo "No Result Found!";
    }
}

?>



<div class="content">
    <form method = "post">

          <input name="search" type="text" size="30" placeholder="Search..."/>

          <input type="submit" value="Search"/>

          </form> 

0 个答案:

没有答案
相关问题