Adding a search bar to search certain fields of MySQL in php

Discussion in 'Databases' started by thexyz, Sep 2, 2011.

  1. #1
    Good people of the forum world,

    I am looking to add my own search bar and not one reliant on third party scripts. I just want it to be able to search certain fields of a directory.

    eg. search for:

    • <title>
      <description>
      <url>

    Any tutorials on a straight forward tutorial will be appreciated, thanks.
     
    thexyz, Sep 2, 2011 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    You use a SELECT query to select all records with the data you want:

    SELECT * FROM mytable WHERE title LIKE "this site%"

    (You get the contents of the WHERE clause from the user.)

    Then you display the records returned.
     
    Rukbat, Sep 2, 2011 IP
  3. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #3
    If you want to search in MySQL database, then all it needs is a form on front end and search queries to fetch result from the user input. After its matter of displaying the results.

    Alternate is you can implement Google Custom Search which would be quick, easy and beneficial.
     
    mastermunj, Sep 19, 2011 IP
  4. amydre

    amydre Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Like mastermunj posted, all you need is a form and search queries to fetch the results. You can use like or fulltext search queries. Google custom search will work if your site is setup properly and if it's not very large.
     
    amydre, Oct 20, 2011 IP