Prev: login to protected directory by php
Next: [ENCODING QUEUE] - anyone think of a good way to setup aqueuing system so everyone gets their turn
From: DealTek on 13 Aug 2010 20:19 Hi all, another newbie question.... I have a recordset from mysql - a list of 20 or so products... 1 - I would like create an edit form to loop through the records and edit a text field called 'favorite' for each of the records - (this, I have done)... 2 - then I would like to submit the form and update all records favorite field at once... Q: so how do I create the form and response page so that I can update all 20? I'm sure it involves numbering the form names like: $c = 1 - then increment counter <input name ="favorite<?php echo $c; ?>" ... (1 - text) <input name ="favorite<?php echo $c; ?>" ... (2 - text) <input name ="favorite<?php echo $c; ?>" ... (3 - text) <input name ="favorite<?php echo $c; ?>" ... (4 - text) ....not sure how to loop thru these on the response / update page to get them updating correctly.... -- Thanks, Dave - DealTek dealtek(a)gmail.com [db-10]
From: chris h on 13 Aug 2010 20:33
you can do it like this... <input name="field[]" value="zero" type="text" /> <input name="field[]" value="one" type="text" /> <input name="field[65]" value="sixty-five" type="text" /> <input name="field[car]" value="truck" type="text" /> on the php side this would equate to... echo $_POST['field'][0]; // prints "zero" echo $_POST['field'][1]; // prints "one" echo $_POST['field'][65]; // prints "sixty-five" echo $_POST['field']['car']; // prints "truck" provided the form is submitted via a POST method. Take care to ensure you have the right index on the array. Chris. On Fri, Aug 13, 2010 at 8:19 PM, DealTek <dealtek(a)gmail.com> wrote: > Hi all, > > another newbie question.... > > I have a recordset from mysql - a list of 20 or so products... > > > 1 - I would like create an edit form to loop through the records and edit a > text field called 'favorite' for each of the records - (this, I have > done)... > > 2 - then I would like to submit the form and update all records favorite > field at once... > > Q: so how do I create the form and response page so that I can update all > 20? > > I'm sure it involves numbering the form names like: > > $c = 1 - then increment counter > > <input name ="favorite<?php echo $c; ?>" ... (1 - text) > <input name ="favorite<?php echo $c; ?>" ... (2 - text) > <input name ="favorite<?php echo $c; ?>" ... (3 - text) > <input name ="favorite<?php echo $c; ?>" ... (4 - text) > > > > ...not sure how to loop thru these on the response / update page to get > them updating correctly.... > > > > > -- > Thanks, > Dave - DealTek > dealtek(a)gmail.com > [db-10] > > > > |