<?php
include 'db.inc.php';
//function that well return search results
//takes the keywords entered by user
function search_results ($keywords){
//code here
$returned_results= array();//array that will contain results
$where= ""; // constract of query for results
$keywords = preg_split ('/[\s]+/', $keywords);
//function split values by space
// (hello aya) is like ( hello aya )
$total_keywords = count($keywords);
//count number of words entered ex(ayoy adel =2 , a b c s = 4)
foreach ($keywords as $key=>$keyword){
$where .="`keywords` LIKE '%$keywords%'";
if ($key != ($total_keywords -1 )){
$where .= " AND " ;
}
}
$results = "SELECT `title` , `subject` , `id` FROM `` WHERE $where ; ";
}
//array begins from 0 , this erro
//$key=>$keyword key=0 , 1, 2 $keyword value in database
//
//
//
/*$sqlQuery= " SELECT `keywords` FROM `question` WHERE `keywords` LIKE `%hci%` AND `keywords` LIKE `%what%` ";
*/
?>
问问题
88 次