SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Jul 2005
    Posts
    456
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    simple search feature

    hi, i have a text field that the user can input a keyword to search on. i want it to search two fields in my database: productName and productDetails. can someone tell me the sql i would have to use? I know it would be a mixture of using the WHERE and LIKE commands.
    many thanks

  2. #2
    SitePoint Enthusiast briercan's Avatar
    Join Date
    Nov 2006
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If all you want to do is search for a bit of text, you can use:
    Select * from products
    WHERE productName like '%yoursearchstring#' or productDescription like '%yoursearchstring%'
    If you need to have the search set up to get a result if your products contain "Hot dogs", and the user searches for "dogs hot", then you need to use some sort of loop within the sql.
    Hope this helps.
    thisplaceiknow.com - Search for and submit real-life places.
    (Those are the ones that don't start with http://)

  3. #3
    SitePoint Evangelist
    Join Date
    Jul 2005
    Posts
    456
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks brier, thats what i wanted.
    - G


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •