Search multiple fields in a single table
Results 1 to 5 of 5

Thread: Search multiple fields in a single table

  1. #1
    Junior Member
    Join Date
    Dec 2006

    Search multiple fields in a single table

    I am trying to create a search facility for my website and need to be able to search multiple fields in a single table in MySQL, I am using dreamweaver, and my PHP and SQL knowledge is minimal, I donít have a problem being able to search a single field in the database and displaying the results as dreamweaver generates the code for me.

    The table I am trying to create the search for is called LEWISHAM and the fields within the table I need to search are; towna, townb, townc, postcodea, postcodeb, postcodec

    If someone could please help me or point me in the right direction where I could learn more about searches or give me some tips to help that would be fantastic



  2. #2
    Beware: Crazy Scientist leatherback's Avatar
    Join Date
    Mar 2002
    Small border town between Netherlands and Germany
    something like this:

    PHP Code:
    $query "
    select towna, townb, townc, postcodea, postcodeb, postcodec 
    from LEWISHAM 
    postcodea = "
    (townb = "
     and postcodea = "
    However... I wonder WHY you have a towna and townb. Sounds like poor database design to me..
    Php 4.* to 5.*. A small step for programmers. But a leap for me!

  3. #3
    Senior Member
    Join Date
    May 2003
    PHP Code:
    $query "select * from LEWISHAM where towna LIKE '%".$_GET['form_value']."%' or townb LIKE '%".$_GET['form_value']."%'"
    You can keep adding or statements to search the other fields. Let me know if you need anything else. I am good at doing this but not at explaining it.


  4. #4
    Junior Member
    Join Date
    Nov 2012
    hello im new here.. Im trying to do search for multiple fields can you please help me?


  5. #5
    Senior Member
    Join Date
    Aug 2008
    London, UK
    Frido, please try not to resurrect dead threads, this one was over 5 years old!

    If you have a question, start a new thread. However, seeing that your question seems to be exactly the same, you could just try what has been posted as the answer for the OP.
    Ashley Sheridan

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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