MDB2 and Quickform_select Array

From: Date: Tue, 19 Sep 2006 18:23:09 +0000
Subject: MDB2 and Quickform_select Array
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-25168@lists.php.net to get a copy of this message
Hi, I would like to fill in an Quickform_select field with data from my database. So actually I'm trying to use mdb2 to fetch the data und the quickform_select statement to render it. Here is my current code: //Database connetion $mdb2 =& MDB2::connect($dsn); $mdb2->setFetchMode(MDB2_FETCHMODE_ASSOC); $query = 'SELECT * FROM myTable'; $result = $mdb2->query($query); $listData = $result->fetchAll(); print_r($result); OUTPUT: Array ( [0] => Array
       (
           [id] => 1
           [name] => Hannover
       )
[1] => Array
       (
           [id] => 2
           [name] => Frankfurt
       )
) Looks fine.. but quickform_select need another structure.. // create select-Field and load data as array $select =& $form->addElement('select', 'list', 'Headline:'); $select->loadArray($result); OUTPUT: <option value="0">Array</option> <option value="1">Array</option> quickform can't look deeper in the array so it take the first level. loadDbResult did't work either.. quickform_select would work fine when the associative array looks like: Array ( [1] => Hannover, [2] => Frankfurt ) But I did not find a way to get this structure by using mdb2. I tried changing fetchMode, using optional paramenter and so on. Is there any chance to get it work? I'm using smarty as template engine, so I could although do it by looping through the array, but I would prefer the quickform way. Many thanks in advance.. Oliver

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