Re: Getting at $_POST values using a loop

From: Date: Tue, 24 Jun 2003 04:38:40 +0000
Subject: Re: Getting at $_POST values using a loop
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-152565@lists.php.net to get a copy of this message
Thanks Ralph and everyone else who posted a hint. I'm using the array method. Much better and, I'm ashamed to admit it, it means I can do away with my hidden input with "number of fields" too... regards, Dave "Ralph" <ralph@nqionline.com> wrote in message news:000801c3394a$01e20a60$6401a8c0@ralphxorostodu... > > echo "<hr>$fieldname:<input name='FieldName[]' > maxlength='25'>"; > > for ($i=0, $n=sizeof($_POST['FieldName']); $i<$n; $i++){ > > // do whatever you need to do with each field > echo $_POST['FieldName'][$i]; > } > > > -----Original Message----- > From: Dave Alger [mailto:news@alger2000.freeserve.co.uk] > Sent: Sunday, June 22, 2003 9:12 PM > To: php-general@lists.php.net > Subject: [PHP] Getting at $_POST values using a loop > > Hi all, > > This one is causing me a few headaches. How should I be doing this? > > On my previous page I've created a series of fields using a loop so that > a > field is created like this: > > echo "<hr>$fieldname:<input name='Field$n' > maxlength='25'>"; > > On my next page then I've got to try to read these values. I could do > this > as $_POST['Field0'], $_POST['Field1'] etc but a loop is what is > required. > > I've tried getting at the value by: > > $a=$_POST['Field$n']; > > and > > $nb='$'."_POST['Field".$n."']"; > $a=$$nb; > > And neither works. How should I be doing it? > > Thanks in advance for all help. > > regards, > Dave > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.491 / Virus Database: 290 - Release Date: 18/06/2003 > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.491 / Virus Database: 290 - Release Date: 18/06/2003

« previous php.general (#152565) next »