fyremoon Posted September 23, 2008 Share Posted September 23, 2008 I'm working with a calendar that uses an array of arrays to store events on a day to day basis, like this: $days = array( 2=>array('link','linked-day'), 3=>array('link','linked-day'), 8=>array('link','linked-day'), 22=>array('link','linked-day'), ); I would like to read these from a database, so I logically tried this: $select="SELECT * FROM calendar WHERE month='$month' ORDER BY day"; $rows = mysql_query($select,$calendar); while ($row = mysql_fetch_row($rows)) { $day=$row[1]; $daysx.="$day=>array('link','linked-day'),"; } $days=array($daysx); I was hoping I would get the same result but although when I echo the value of $daysx, it looks similar I don't get a result. Does anyone know how I can populate such an array using a database? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/125540-solved-a-coding-solution-required/ Share on other sites More sharing options...
Barand Posted September 23, 2008 Share Posted September 23, 2008 I'll assume the col names are day, link, linked_day (as SELECT * tells us nothing) $select="SELECT day, link, linked_day FROM calendar WHERE month='$month' ORDER BY day"; $rows = mysql_query($select,$calendar); $days = array(); while (list ($day, $link, $linked_day) = mysql_fetch_row($rows)) { $days[$day]= array ($link, $linked_day); } Link to comment https://forums.phpfreaks.com/topic/125540-solved-a-coding-solution-required/#findComment-649101 Share on other sites More sharing options...
fyremoon Posted September 24, 2008 Author Share Posted September 24, 2008 Thank you so much, that solved the problem. Link to comment https://forums.phpfreaks.com/topic/125540-solved-a-coding-solution-required/#findComment-649377 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.