Php搜索栏无法显示结果

时间:2014-11-17 16:22:02

标签: php html mysql sql

    if(isset($_POST['search']) && $_POST['search'] != ""){
        $safe_value = $_POST['search'];
        $safe_value = preg_replace("#[^0-9a-z]#i","",$safe_value);
        $query = mysqli_query($connection,"SELECT * FROM quote WHERE quoteID LIKE '%$safe_value%' OR quotations LIKE '%$safe_value%' OR author LIKE '%$safe_value%' OR genre LIKE '%$safe_value%'");


        if($count == 0){
            echo "No Results Found";
        }else{
            while($row = mysql_fetch_assoc($query)){
                $quotations = $row['quotations'];
                $author = $row['author'];
                $genre = $row['genre'];

            echo " <p> ";
            echo " Quote Number : $quoteID <br> ";
            echo " Author : $author <br>";
            echo " Quotations : $quotations <br>";
            echo " Genre : $genre <br>";
            echo "<hr> </p>";
            }
        }
    }

<form method="post" action="search.php">
 <input class="sb-search-input" placeholder="Enter your search term..." type="text" value="" name="search" id="search">
 <input class="sb-search-submit" type="submit" value="submit">
 <span class="sb-icon-search"></span>
</form>
  

我的数据库由此组成;

     

QuoteID |报价|作者|类型|

     
      
  1. | &#34;一些引用&#34; | &#34;一些作者&#34; | &#34;某些类型&#34; |

  2.   
  3. | ....等等..

  4.   

我计划从搜索栏中搜索,它会显示数据库中的所有信息。

它显示数据库已连接,但它没有显示结果。我错过了什么?

//在此处为我的网页添加了一个问题链接(搜索栏的顶部橙色图标)

访问http://khcy4dau.mercury.nottingham.edu.my/Assignment%20/

0 个答案:

没有答案