Search query for advance search of Matrimonial website

Discussion in 'PHP' started by tinyprogram, Oct 19, 2011.

  1. tinyprogram

    tinyprogram New Member

    Joined:
    Jan 31, 2011
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Web Developer
    Location:
    Cyber World
    Hi...

    I am getting trouble in writing a query for multiple selection in a Matrimonial website..

    e.g. If someone searches for a groom with religion as Hindu or Muslim, caste as Kayastha, Shudra, Vaishya or Kshtriya and profession as Engineer or Manager, then how to write query for it?
    I am taking input from listbox...with multiple selection...l

    Thanks in advance :)
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Use the IN operator in the query.

    Religion in ('Hindu', 'Muslim') AND/OR Caste in ('Kayastha','Kshtriya')
     
  3. tinyprogram

    tinyprogram New Member

    Joined:
    Jan 31, 2011
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Web Developer
    Location:
    Cyber World
    shabbir...thanks for your reply...

    but there are 'n' numbers of options and suppose the user opts for 'm' number of options, then how to write query?
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    It does not matter how many options user selects and you can add each of them in the IN query.
     
  5. tinyprogram

    tinyprogram New Member

    Joined:
    Jan 31, 2011
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Web Developer
    Location:
    Cyber World
    ok...but I don't know that how many options that user will select at runtime...may be he can select 5 options out of 10, 10 out of 10 or any other number...

    My question is how to run query when I am not sure about the number of options the user had selected.
     
  6. thevikasonline

    thevikasonline New Member

    Joined:
    Nov 14, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Software Developer
    Location:
    India
    Make a separate search table which form indexes with others related tables. Fire your query direct to this table and make join with others table by the help of result you get from this.
     
  7. jhonden

    jhonden New Member

    Joined:
    Sep 13, 2011
    Messages:
    190
    Likes Received:
    4
    Trophy Points:
    0
    Do colone search for exact and prompt search.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice