Re: HTML_Quickform question

From: Date: Wed, 09 Jun 2004 06:34:37 +0000
Subject: Re: HTML_Quickform question
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-13026@lists.php.net to get a copy of this message
Thanks for the help. John "Stefan Ohrmann" <bshell@gmx.net> wrote in message news:40C6366D.9030602@gmx.net... > Hello, > > Am 08.06.2004 22:27 schrieb John Lawson: > > I am trying to populate a list box with data from a database. I am using > > the following syntax, where select_data is an array containing descriptions; > > $form->addElement('select', > > 'select_name', // name of select > > 'select_label', // label for select > > $select_data); > > > > I just can't see how to set the"<option value>" to values I can use > > - I > > don't want the default option values which are being created. (0,1,2...n) > > > > Is this possible to achieve? > > Sure, you have to pass an associative array, where the keys are your > values for the options tag. For example following data array: > > $arr = array ('Franz' => 'Option 1', > 'Helmut' => 'Option 2'} > > results in > > <option value="Franz">Option 1</option> > <option value="Helmut">Option 2</option> > > greetings, > > Stefan

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