Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Prepopulating two dropdownmenus from MySQL

    Hi,

    I'm using MySQL/PHP on the server side and I have a database with customers and customer specific products. I have a form where i would like to have a dropdown menu for both customers and products. Customer menu is prepopulated from DB and depending on that selection a new SQL-query will be made with that customers name and ultimately populate the next menu with specific customers products.

    I am not familiar with JS so im kind of lost with it. I suppose i have to pass a queried customer array from PHP/HTML to JS and so forth. Or is JS a proper tool for this problem in the first place? Below is some simple code I have.

    Code:
    .
    ..
    ...
    while ($row=mysql_fetch_array($result)) {
          $customer=$row["customername"];
          $options.="<OPTION VALUE=\"$customer\">".$customer.'</option>';	
    }
    
    echo("<SELECT NAME=customername><OPTION VALUE=0><?=$options?>< /SELECT>");
    
    ...
    ..
    .
    Cheers,

    Bigfinn

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,862
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Customer menu is prepopulated from DB and depending on that selection a new SQL-query will be made with that customers name and ultimately populate the next menu with specific customers products.
    Take a look at http://bonrouge.com/~chain_select_ajax
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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