Re: QF: while loop defaultvalues and unique identification

From: Date: Tue, 07 Oct 2003 15:56:35 +0000
Subject: Re: QF: while loop defaultvalues and unique identification
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-8321@lists.php.net to get a copy of this message
<keith@setuplinux.com> wrote : > This problem has been kicking me for almost a week now. I figured out > have to display the form the way I want in a spread sheet type format, > display a number of rows from a while loop depending on the rows in the > db with a match: > > email first last > [.....][.....][.....] > [.....][.....][.....] > [.....][.....][.....] > > My issue is I have to give some sort of unique row identifier so when I > click my "update" later I can somehow parse though the data. The way I > thought to do that was basically "$fieldname_$rowidentifer" which seems > to work ok until I get ready to do my update statement. Here is alittle > example: > > $form->addElement('text', "email_$emseed_ctid", null, > 'size="15"'); > $form->addElement('text', "fname_$emseed_ctid", null, > 'size="10"'); > $form->addElement('text', "lname_$emseed_ctid", null, > 'size="10"'); > > So I end up with a bunch of data like this: > > fname_1 lname_1 email_1 fname_2 lname_2 email_2 fname_3 lname_3 email_3 > > Then I have to split the names of the fields and try to make an array > ,etc ,etc. It gets painfull. > > I thought a easier way would be to just make a array out of the data > like so: > > $form->addElement('text', "email['$emseed_ctid']", null, > 'size="15"'); > $form->addElement('text', "fname['$emseed_ctid'], null, > 'size="10"'); > $form->addElement('text', "lname['$emseed_ctid'], null, > 'size="10"'); > > but then I can't figure out a way to make the $defaultValue's work. I > know there is probally a really easy way to do this and would really > apprecaite a push in the right direction. > > Basically I need a easy way to uniquely identify rows so I can split > apart the information and do my update statement. Use groups. while(I have $emseed_ctid left) { $fields = array(); $fields[] =& HTML_QuickForm::createElement('text', "email", null, 'size="15"'); $fields[] =& HTML_QuickForm::createElement('text', "email", null, 'size="15"'); $form->addGroup($fields, $emseed_ctid, 'Label'); } Bertrand Mansion Mamasam

« previous php.pear.general (#8321) next »