-1
<?php 

  $k = $_GET['K'];

  $terms = explode(" ", $k);

  $query = "SELECT * FROM search WHERE ";

  foreach ( $terms as $each) {

          $i++;

      if($i == 1)

      $query .= "keywords LIKE '%$each%' ";

      else

        $query .= "OR keywords LIKE '%$each%' ";

}

要求(“连接.php”);

$query = mysql_query($query);

$numrows = mysql_num_rows($query);

如果($numrows > 0){

而 ($rows = mysql_fetch_assoc($query)){

        $id = $rows['id'];
        $title = $rows['title'];
        $description = $rows['descriptions'];
        $keywords = $rows['keywords'];
        $link = $rows['link'];


        echo "<h2><a href = '$link'> $title </a></h2> 
        $description <br /> <br />";

}

}别的

echo "没有找到\" $k \""的结果;

mysql_close();

4

1 回答 1

1

你可以这样做

$query = "SELECT DISTINCT *FROM search WHERE ";
于 2014-11-26T20:43:23.383 回答