i have an array with the result of the search term. please take a look at blow code
$keyword = trim($_POST['keyword']);
$keyword = preg_replace('!\s+!', ' ', $keyword);
$words = explode(' ', $keyword);
$keyword = str_replace(" ","+",$keyword);
$query = "SELECT * FROM videos WHERE MATCH (video_name) AGAINST ('$keyword' IN BOOLEAN MODE)";
$q_result = mysql_query($query) or die (mysql_error());
if (mysql_num_rows ($q_result) != 0) {
while ($row = mysql_fetch_assoc($q_result)) {
$id = $row['id'];
$video_name = $row['video_name'];
$result[]= "$id $video_name";
}
}
foreach($result as $res){
echo "$res <br>";
}
}
it is working perfectly. but it is displaying the result in ascending order to id. what I want is if a row contains all or maximum keywords it should be the first element of the array.
let me explain further. suppose we have 3 rows id video_name 1 how to create php code. 2 php language scope in future. 3 the future of php.
if a user searches "PHP language scope in future" the array should be arranged by id 2,3,1
here is the output. as you can see query I have searched 3 words
hope its clear