Forms with a variable number of fields

后端 未结 3 987
情书的邮戳
情书的邮戳 2020-12-18 08:34

I\'m attempting to create a sort of marketplace. Each item on the market has a type (i.e. the item being sold), a value, a quantity, a seller name, and an id, and all of thi

3条回答
  •  星月不相逢
    2020-12-18 09:14

    My problem is that since each input field is the result of a while loop of unknown iterations, I can't simply hard code a name into each field. I've tried using a counter variable to keep track and make names, but it doesn't seem to be working.

    Name your inputs like this:

    
    
    
    

    Then, in your PHP, $_POST['myName'] or $_GET['myName'] is an array.

    This is documented here.


    On a related note, in order for the program to work, each field needs to send two values - the id (which I can use to look up the rest of the entry's values) and the quantity that the user wishes to purchase. I've been doing this with a hidden field before the input quantity field.

    Sounds fine to me.

提交回复
热议问题