mysqli_fetch_assoc()期望参数1为mysqli_result,布尔值

时间:2019-05-15 17:38:31

标签: php sql search mysqli

我写了searching code,但是出了点问题...

  

警告:mysqli_fetch_assoc()期望参数1为mysqli_result,在第241行的D:\ XAAMP \ htdocs \ ict \ search.php中给出的布尔值

<?php
$connect = mysqli_connect("localhost","root","","ict") or die("Error");
?>

<form method="post">
   <input type="text" name="search" class="search">
   <input type="submit" name="submit" value="search">
</form>

<?php
        if(isset($_POST['submit'])) {
            $search = explode(" ",$_POST['search']);
            $count = count($search);
            $array = array();
            $i = 0;
            foreach($search as $key) {
                $i++;
                if($i < $count)
             $array[] = "CONCAT ('model_name') LIKE '%".$key."%' OR "; 
            else 
             $array[] = "CONCAT ('model_name') LIKE '%".$key."%'";
            }
            $sql = "SELECT * FROM 'shoes' WHERE ".implode("", $array);
            echo $sql;
            $query = mysqli_query($connect, $sql);
            while($row = mysqli_fetch_assoc($query)) 
               echo "<p><strong>". $row['model_name'] ."</strong></p>
                   <h4>$". $row['price'] ."</h4>
                  <p>Color : ". $row['color']." <br />
                 Brand : ". $row['brand'] ." <br />";
        }
       ?>

0 个答案:

没有答案