Re: Accessing variables from a form

From: Date: Wed, 21 Feb 2001 17:08:34 +0000
Subject: Re: Accessing variables from a form
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-41001@lists.php.net to get a copy of this message
Don wrote: > > Hi, > > I'm in a quandary here. I have a form which contains sever tables each > containing similar fields. The number of tables are dynamic based on > vales I retrieve from a database. Each table has the following fields: > > ... > Maybe this approach is simpler. If you create your fields like this: <? ... echo '<input type="text" name="name['.$rownum.']">'; echo '<input type="text" name="phone['.$rownum.']">'; echo '<input type="text" name="fax['.$rownum.']">'; ... ?> then after submitting you will have arrays: $name, $phone, $fax. Now, for values from first table use: $name[0], $phone[0], $fax[0]. For second: $name[1], $phone[1], $fax[1]. etc... And there's no need for huge amount of variables. Hope this helps. :) -- Pavel a.k.a. Papi

« previous php.general (#41001) next »