Re: Dynamic columns and Flexy again
| From: | Dan Rossi | Date: | Mon, 10 Oct 2005 05:52:37 +0000 |
| Subject: | Re: Dynamic columns and Flexy again | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-21305@lists.php.net to get a copy of this message | ||
Apologies i finally got it :|
$i = 0;
$this->ar = array();
$arr = $this->_db->queryAll("SELECT * from table");
$cols = 2;
$loop = ceil(count($arr) / $cols);
for ($j=0;$j <= $loop;$j++) {
$this->ar[$j] = array_slice($arr,$i,$cols);
$i = $i + 2;
}
On 10/10/2005, at 3:35 PM, Dan Rossi wrote:
Hi there, I had asked some questions earlier regarding formatting an array pulled from the database to generate dynamic columns in flexy to a given column length. Is there still no method in flexy to handle this automatically ? Ive had no luck trying to format an array i get from the db using MDB2 like $db->queryAll('select * from table'); Im needing to slice that up into say 2 columns and however many rows needed, im trying to hack this up as there seems to be no method, however is a lesser block based templating system i used years ago it had the column function ?? Any ideas ?? $i = 0; $this->ar = array(); $arr = array(0=>array('title'=>'test1'),1=>array('title'=>'test2'),2=>array('title'=>'test3'),3=>array('title'=>'test4'),4=>array('title'=>'test5'),5=>array('title'=>'test6'),6=>array('title'=>'test7'),7=>array('title'=>'test8'),8=>array('title'=>'test9'),9=>array('title'=>'test10'),10=>array('title'=>'test11')); $cols = 2; $loop = ceil(count($arr) / $cols); $r = 0; for ($j=0;$j <= $loop;$j++) { $this->ar[$i % $cols == 0 ? $i++ : $i] = array_slice($arr,$j + $cols,$cols,true); } --PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php