PHP search box

Discussion in 'PHP' started by trenttdogg, Feb 19, 2013.

  1. #1
    Hello World,
    I'm trying to put a search feature on my site for users to easily find the content they are looking for. I don't want the google thing. I don't even know if that will work. The site is db driven so I figure PHP would be a good option. Any suggestions? Also, are php searches functional across the entire db or table specific. Just wondering before I set up multiple tables and then find out the search can only retrieve data from one table.

    Thanks,
     
    trenttdogg, Feb 19, 2013 IP
  2. scottlpool2003

    scottlpool2003 Well-Known Member

    Messages:
    1,708
    Likes Received:
    49
    Best Answers:
    9
    Trophy Points:
    150
    #2
    They can be searched across the entire db by using inner/cross joins. I started using MSSQL a few months back and on Windows Server 2008 I have VB built in which has a query builder. At first I struggled a little building my queries using that as opposed to simply writing them myself. Ever since though, I can't believe how easy it actually is and my queries are SO much more simple. I used to have about 7 queries doing something like a sitewide search where now its put into 1 single query making it faster, more reliable and easily manageable. There's a query builder in PHPMyAdmin too I think, but if you don't have it I'd definitely recommend downloading some other equivalent.
     
    scottlpool2003, Feb 20, 2013 IP
  3. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #3
    The graphic query builder in Access makes building a query trivial. (I think MSSQL has the same type of utility.) The query you build will also work with MySQL. Even making inner or outer joins is simple.
     
    Rukbat, Feb 23, 2013 IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    28,898
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #4
    Sqlyog has a good query builder too.... however I'd suggest to this particular user that he sticks to "the google thing" given that he doesn't know the first thing about database queries.
     
    sarahk, Feb 24, 2013 IP
  5. trenttdogg

    trenttdogg Greenhorn

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    8
    #5
    correct. I know nothing.

    but you do, so teach me;)
     
    Last edited by a moderator: Feb 24, 2013
    trenttdogg, Feb 24, 2013 IP
  6. sarahk

    sarahk iTamer Staff

    Messages:
    28,898
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #6
    The first thing I'll teach you is not to be too proud to use google search. When you set up the styles properly it can look really good.

    The problem that you have with search is that the user is putting in the info.
    How do you check for sql injections? and stay ahead of the game
    How do you check for similies? If I search for ABC I also want the results for A.B.C.

    and the list goes on. Let Google do all the hard work!
     
    sarahk, Feb 24, 2013 IP
  7. trenttdogg

    trenttdogg Greenhorn

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    8
    #7
    So you are saying that Google IS a viable option for a db driven site?
     
    trenttdogg, Feb 24, 2013 IP
  8. trenttdogg

    trenttdogg Greenhorn

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    8
    #8
    Yeah, the "google thing" won't work for what I need. It has to be something that
    1) Queries the db get the matches
    2) Returns them into an array
    3) Array is displayed withing a certain container on my page.

    Can someone steer me in the right direction for doing this?
    Thanks,
     
    trenttdogg, Feb 24, 2013 IP
  9. sarahk

    sarahk iTamer Staff

    Messages:
    28,898
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #9
    Ok, so you need to find a tutorial on querying your database and displaying the results. From there you need to look through your database for the fields that need to be queried.

    Consider the search on this forum. When you search the data checks posts, notes, registration details to search for a match according to the rights of the user. It's very complex, very fast and took Shawn countless hours to get right.

    If you decide it's too much take a look at http://www.nzpif.org.nz/items/view/55177/search?q=blue chip and see how the Google Search can look - google has indexed all of the pages, it knows all of the links, it interprets the query according to what it knows about the site. I'm a damned experienced developer but I can't see the value for money for my client by recreating the wheel.
     
    sarahk, Feb 25, 2013 IP