Re: [solution] QuickForm_advmultiselect - can you open the form with the SELECTED list already populated from a data set?

From: Date: Wed, 31 Aug 2005 00:09:24 +0000
Subject: Re: [solution] QuickForm_advmultiselect - can you open the form with the SELECTED list already populated from a data set?
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-20676@lists.php.net to get a copy of this message
--- Laurent Laville <pear@laurent-laville.org> wrote: > l Burnerheimerton wrote: > > > > I'm not sure how to do this using Pear DB: I've > tried > > the following three methods to get what you said I > > needed and it still gives my the blank entry in > the > > selected column: > > > > $selected_people = $db->getCol("SELECT > > CONCAT(lastName, \", \", firstName) FROM people > WHERE > > ID = 17"); > > > > $selected_people = $db->getOne("SELECT > > CONCAT(lastName, \", \", firstName) FROM people > WHERE > > ID = 17"); > > > > $selected_people = $db->query("SELECT > CONCAT(lastName, > > \", \", firstName) FROM people WHERE ID = 17"); > > > > Well it's depends of your database structure, > "people" table > and what you expected to get once the form will be > post. > > CONCAT(lastName, \", \", firstName) : > this part is only the visible content that will be > display on both lists > (select boxes: AVAILABLE=$all_people, > SELECTED=$selected_people). > > You also need a key (table column) which identity > the label > CONCAT(lastName, \", \", firstName) > itself. > > remember my example: > > $all_people = array('farell' => 'laurent laville'); > (1) (2) > > (1) should be a people.column (not yet present in > your query) > (2) this content is === CONCAT(lastName, \", \", > firstName) > > i hope WHERE ID = 17 identify a list and not only a > single row > otherwise you have found the (1) missing. > > It's definitively now a problem to get information > in good format rather > than a HTML_QuickForm_advmultiselect bug or wrong > implementation. > > regards > Laurent > > -- > PEAR General Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Right, the first query I wrote is wrong and not what is used either. It should read: $all_people = $db->getCol("SELECT ID, CONCAT(lastName, \", \", firstName) FROM people WHERE ID = 17"); $selected_people = $db->getCol("SELECT CONCAT(lastName, \", \", firstName) FROM people WHERE ID = 17"); I only included one field because you wrote earlier that the selected list should only be one data point in the array: > $selected_people = array('farell'); I used "WHERE id=17" just to ensure I got a different results than the first query. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com

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