How do implement search option in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • somaskarthic
    New Member
    • Aug 2006
    • 60

    How do implement search option in php

    Hi

    I need to implement search option in php page. I need the best method used to implement this feature.
    I Followed the following steps to include search option. But i don't whether is best.

    (i) In mysql database , each table contains a field 'keyword' ,'url'. Records relevant to the typed text is fetched and if it is clicked , the target url is fetched from the database and displayed. But it might be tedious for more data.

    I need the best and actual method used to implement search option in a portal.

    Thanks in advance
    Somaskarthic
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Not really shure what you mean but ok...

    Searching isn't really done in php, it would be done in the database. MySQL has some nice search features.

    This is a nice simple way to search a MySQL table, but works quite well in my exerience.
    Note: this is case insensitive.

    Code:
    SELECT data FROM table WHERE column LIKE '%keyword%';

    If you want the more advanced option, Fulltext searches are also possible in MySQL. Fulltext search is more advanced, not returning only when a keyword is found but also returning related text.

    Before you use fulltext search you must define a Fulltext index in your table, for an existing table you'd want to alter it thusly:

    Code:
    ALTER TABLE tablename
    ADD FULLTEXT INDEX (columnname)
    Then when you want to search you could use a qyery that looks something like this.

    Code:
    SELECT * FROM tablename WHERE MATCH (columnname) AGAINST ('keyword')
    Hope this helps :-)

    Comment

    • mainul
      New Member
      • Sep 2006
      • 51

      #3
      send me ur table sturcture and let me know what do u want to display. let me help u !!

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        See same question/posts in forum How to search a pattern in MySQL

        Ronald :cool:

        Comment

        • Monsieur2000
          New Member
          • Jan 2008
          • 1

          #5
          Originally posted by mainul
          send me ur table sturcture and let me know what do u want to display. let me help u !!
          Would you be able to help me implement a search function for my data?

          Comment

          Working...