Dynamic Conditions/Criteria in PHP form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BigM
    New Member
    • Aug 2007
    • 10

    #16
    Sorry guys, could I ask a follow up question on this.

    Once you've got this working, how do you harvest the entered info to post to a database?

    I've been playing around with some different php ideas to do it but no luck so far.

    Comment

    • ronnil
      Recognized Expert New Member
      • Jun 2007
      • 134

      #17
      Originally posted by BigM
      Sorry guys, could I ask a follow up question on this.

      Once you've got this working, how do you harvest the entered info to post to a database?

      I've been playing around with some different php ideas to do it but no luck so far.
      Hi BigM

      Taking the code you posted above, you see you named your textfield "criteria[]"

      as you know the field's values can normally be collected with $_POST or $_GET. This is actually still the case, the only thing is that when you put in the square brackets, your result will be an array :)

      if you wanted to gather all the inputfields you would use something like

      [CODE=php]
      <?php
      foreach($_POST['criteria'] as $value)
      {
      echo $value;
      }
      ?>
      [/CODE]

      if you try to print out $_POST['criteria'] you will most likely see "Array".

      Comment

      • ronnil
        Recognized Expert New Member
        • Jun 2007
        • 134

        #18
        @BigM again :)

        you need to put your formfields inside the form tag, also if you wrap a div or table tag around them, if you don't, nothing will get send with the form :)

        and make sure to set the method attribute too, cause the GET method might not always be the browser default :)

        Comment

        • BigM
          New Member
          • Aug 2007
          • 10

          #19
          Thanks very much ronnil, working perfectly now. :)

          Comment

          Working...