473,394 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

how i can search multiple word search in Mysql Database

***> 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.


Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     include("connection.php");
  3.     @ob_start();
  4.     session_start();
  5.     $GLOBALS['q']=isset($_GET['q']) ? htmlspecialchars(urldecode(urlencode($_GET['q']))):"";
  6.     $GLOBALS['displayQ']=$GLOBALS['q'];
  7.     $GLOBALS['q']=strtolower($GLOBALS['q']);
  8.     $GLOBALS['p']=isset($_GET['p']) && is_numeric($_GET['p']) ? $_GET['p']:1;
  9.     $GLOBALS['dbh']=$dbh;
  10.  
  11.     function htmlFilt($s){
  12.      $s=str_replace("<", "&lt;", $s);
  13.      $s=str_replace(">", "&gt;", $s);
  14.      return $s;
  15.     }
  16.     function head($title="", $IncOtherCss=array()){
  17.      $title=$title=="" ? "Search" : $title." - ";
  18.      /* Display The <title> tag */
  19.      echo "<title>$title</title>";
  20.      /* The Stylesheets */
  21.      $cssFiles = array_merge(
  22.       array(
  23.        "all",
  24.        "http://fonts.googleapis.com/css?family=Poiret+One"
  25.       ),
  26.       $IncOtherCss
  27.      );
  28.      foreach($cssFiles as $css){
  29.       $url=preg_match("/http/","/wwww/", $css) ? $css : HOST."/spills/$search.css";
  30.       echo "<link href='".$url."' async='async' rel='stylesheet' />";
  31.      }
  32.  
  33.  
  34.  
  35.  
  36.  
  37.     /* Results */
  38.     function getResults(){
  39.      $q=$GLOBALS['q'];
  40.      $p=$GLOBALS['p'];
  41.      $start=($p-1)*10;
  42.      if($p!=null){
  43.       $starttime = microtime(true);
  44.       $sql=$GLOBALS['dbh']->prepare('SELECT title, url, description FROM search WHERE `title` LIKE :q OR `url` LIKE :q OR `description` LIKE :q ');
  45.       $sql->bindValue(":q", "%$q%");
  46.       $sql->execute();
  47.       $trs=$sql->fetchAll(PDO::FETCH_ASSOC);
  48.       $endtime = microtime(true);
  49.       if($sql->rowCount()==0 || $start>$sql->rowCount()){
  50.        return 0;
  51.       }else{
  52.        $duration = $endtime - $starttime;
  53.        $res=array();
  54.        $res['count']=$sql->rowCount();
  55.        $res['time']=round($duration, 4);
  56.        $limitedResults=array_slice($trs, $start, 12);
  57.        foreach($limitedResults as $r){
  58.         $res["results"][]=array($r['title'], $r['url'], $r['description']);
  59.        }
  60.        return $res;
  61.       }
  62.      }
  63.     }
  64.     ?>
Nov 24 '15 #1
1 1892
adriancs
122 100+
Expand|Select|Wrap|Line Numbers
  1. select * from member where name like '%word1%word2%word3%';
Dec 23 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Dave | last post by:
Apologies for the newbie question. I have created a vb.net program for my company that is designed to work with Word Templates (about forty of them that we commonly use) that are selected by the...
2
by: ameshkin | last post by:
I know this is probably not too hard to do, but how do I display multiple rows of a mysql query/recordset. Im having trouble doing this. I don't just want to display them, but I want to make sure...
3
by: tdemartino | last post by:
I've been searching for days, using MS help and I can't find the answer on my own. I have this code in my Access Form: If Not IsNull(Me.txtFilterDescriptionMatName) Then...
1
by: almu | last post by:
Hi all, I need help to build a set of queries in PHP/MySQL for a multiple-parameter search form, whereby the user will be able to search any number of ways (upto seven) Thanks
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
1
by: jarremw | last post by:
hello all, i am making a database to hold some scanned pdf's so i was wondering how would i go about saving them in the mysql database? would i put the file in the database or just link to it? so if...
11
by: nse111 | last post by:
<?php //header('Content-Type: image/jpeg'); header('Content-Type: text/html'); @mysql_connect("localhost","root","dba") or die("Error"); @mysql_select_db("gallery"); $result =...
2
by: rajsrmc | last post by:
Hello pals i have connected mysql table in gridview, how to do search by using the particular word from the text box and suggest any ways to get the result in grid view Please send some...
2
by: rajsrmc | last post by:
Hello experts Let's say I have a gridview with some columns like, title, name, funding agency. Here's an example of what I want to do: I want to display all the records in the gridview to start....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.