<?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%' ";
}
require("connect.php");
$query = mysql_query($query);
$numrows = mysql_num_rows($query);
if($numrows > 0){
while ($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 />";
}
}else
echo "No results found for \"$k\"";
mysql_close();
You can do like this
$query = "SELECT DISTINCT *FROM search WHERE ";