SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Dublin
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Generating an SQL search query from Drop Down Menu

    Hi, this is something i can't get my head around even though it's not too difficult a concept.

    I have a site in php and I'm connecting to a MYSQL database.

    I want the user to select conditions from drop down menus and then submit.

    For example (a travel agents).

    Drop down menu 1: Contains a list of Countries (eg France, Germany.....

    Drop down menu 2: Contains a list of prices ($100, $200

    If the user selects France and $200 and clicks Submit then the sql query searches the database where rows = France AND $200 and outputs the results.

    Connecting to the Database and Drop dwon menu design is no problem for me but I don't know how to put the sql statement together. Any help would be most appreciated.

  2. #2
    Non-Member St.'s Avatar
    Join Date
    Nov 2004
    Location
    Cloud #9
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    show sql table structure plz?

    and you want exactly $200 or >= $200?

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Dublin
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I want >=200 and <300.

    The structure of sql is,

    Holiday table with holiday id, Country_name varchar(30), holiday_details varhcar(255), price int (10)

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Code:
    select holiday_id
         , country_name 
         , holiday_details
         , price 
      from holiday
     where country_name = 'france'
       and price >= 200
       and price <  300
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •