www.webdeveloper.com
Results 1 to 3 of 3

Thread: send form data to a separate PHP page

  1. #1
    Join Date
    Dec 2010
    Posts
    25

    Smile send form data to a separate PHP page

    Hey all,

    I am trying to figure out how to send data from a form, which will send X elements, to a PHP page so that, depending on the options chosen in the form, the appropriate data will be retrieved.

    Here is the page, the form is on the left:

    http://www.paulclift.net/CC-MSM/

    As you can see, you can change the number of instruments you send with the form.

    The PHP code will then have to be something like:

    $data = mysql_query("SELECT * FROM works WHERE (instrumentation = menuselection1 AND menuselection2 AND menuselection3 etc) ORDER BY composers, composed DESC")


    Of course, the number of entries send must correspond to the number of elements in the column, so that when 'flute' is selected on its own, only pieces for solo flute are retrieved.

    Is this clear?

    Maaaaaaaaaaaany thanks for your help.

  2. #2
    Join Date
    Dec 2010
    Posts
    25
    hmm I thought that this question would have been easy for you guys! :-)

  3. #3
    Join Date
    Jul 2007
    Location
    Wisconsin
    Posts
    468
    Here's a suggestion:

    Rather than use javascript to try and clone multiple select dropdowns, (which can get really messy once you start adding/deleting) use one dropdown, and add the "multiple" attribute. This will allow you to select more than one option by CTRL+clicking. Change the name to name="instruments[]" (with the brackets) so the selections are passed as an array.

    You can use the mysql IN clause to search in the array:
    PHP Code:
    // assuming you sanitize your POST variables...
    $instruments implode(",",$_POST['instruments']);  
    $sql "SELECT * FROM `table` WHERE instruments IN ($instruments)"

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
  •  
HTML5 Development Center



Recent Articles