> здесь есть код.как я могу искать несколько слов в базе данных Mysql
i want to search the every word in my database but the results only show with single keyword not the multiple. it is a PDO database when i search single word like facebook then the result is appear if i search two or more word search then the result is not appear.
'
function getResults(){
$q=$GLOBALS['q'];
$p=$GLOBALS['p'];
$start=($p-1)*10;
if($p!=null){
$starttime = microtime(true);
$sql=$GLOBALS['dbh']->prepare('SELECT title, url, description FROM search WHERE `title` LIKE :q OR `url` LIKE :q OR `description` LIKE :q ');
$sql->bindValue(":q", "%$q%");
$sql->execute();
$trs=$sql->fetchAll(PDO::FETCH_ASSOC);
$endtime = microtime(true);
if($sql->rowCount()==0 || $start>$sql->rowCount()){
return 0;
}else{
$duration = $endtime - $starttime;
$res=array();
$res['count']=$sql->rowCount();
$res['time']=round($duration, 4);
$limitedResults=array_slice($trs, $start, 12);
foreach($limitedResults as $r){
$res["results"][]=array($r['title'], $r['url'], $r['description']);
}
return $res;
}
}
}
?>
'
Как вы передали несколько слов? В 1 переменной? – davejal
Вы имели в виду, что я добавляю другую переменную ..? – Altamash
Вы хотите, чтобы ваши поиски искали фейсбуки и связывались в полях? и если да, то как вы хотите передать их к вашему запросу – davejal