arsitek Posted May 31, 2010 Share Posted May 31, 2010 Many example code wrote array data in static. I always confuse how to change it to run in array data from mysql. Static array data is like tihis: $days = array( 13=>array('/weblog/archive/2010/Apr/13 title=day 13 description','linked-day'), 14=>array('/weblog/archive/2010/Apr/14 title=day 14 description','linked-day'), 15=>array('/weblog/archive/2010/Apr/15 title=day 15 description','linked-day'), 16=>array('/weblog/archive/2010/Apr/16 title=day 16 description','linked-day'), 17=>array('/weblog/archive/2010/Apr/17 title=day 17 description','linked-day'), 19=>array('/weblog/archive/2010/Apr/19 title=day 19 description','linked-day'), 21=>array('/weblog/archive/2010/Apr/21 title=day 21 description','linked-day'), 27=>array('/weblog/archive/2010/Apr/27 title=day 27 description','linked-day'), 28=>array('/weblog/archive/2010/Apr/28 title=day 28 description','linked-day'), ); I tried like this ( ): $con=SQL::app()->db; $sql="SELECT * FROM event"; $rows=$con->Command($sql)->queryAll(); $days=array(); foreach ($rows as $row) { $days=array( $row['day']=>array('link title='.$row['description'].'','linked-day' ), ); } Thanks for help Link to comment https://forums.phpfreaks.com/topic/203409-how-to-convert-manually-array-data-to-database-array-data/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.