***> here is the code***.
> when i search single word like GOOGLE then the result is appear
> if i search two or more word search then the result is not appear.
> when i search single word like GOOGLE then the result is appear
> if i search two or more word search then the result is not appear.
Code:
<?php
include("connection.php");
@ob_start();
session_start();
$GLOBALS['q']=isset($_GET['q']) ? htmlspecialchars(urldecode(urlencode($_GET['q']))):"";
$GLOBALS['displayQ']=$GLOBALS['q'];
$GLOBALS['q']=strtolower($GLOBALS['q']);
$GLOBALS['p']=isset($_GET['p']) && is_numeric($_GET['p']) ? $_GET['p']:1;
$GLOBALS['dbh']=$dbh;
function htmlFilt($s){
$s=str_replace("<", "<", $s);
$s=str_replace(">", ">", $s);
return $s;
}
function head($title="", $IncOtherCss=array()){
$title=$title=="" ? "Search" : $title." - ";
/* Display The <title> tag */
echo "<title>$title</title>";
/* The Stylesheets */
$cssFiles = array_merge(
array(
"all",
"http://fonts.googleapis.com/css?family=Poiret+One"
),
$IncOtherCss
);
foreach($cssFiles as $css){
$url=preg_match("/http/","/wwww/", $css) ? $css : HOST."/spills/$search.css";
echo "<link href='".$url."' async='async' rel='stylesheet' />";
}
/* Results */
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;
}
}
}
?>
Comment