[email protected] Posted February 19, 2008 Share Posted February 19, 2008 hi, I'm pretty new at this as I'm using this function to work with a calendar thats being generated. The function receives the year, month and today's date and its suppposed to construct an array containing the elements which need to be linked when the calendar is generated. I need to add the "date => (link , css-class) " into the array. I can't figure out why its not adding items to the array for my calendar table correctly.. any insights? here is the function: [pre]function getcaldays($month, $year, $thisday) { $out = array(); $sql = ""; $sql = "select * from cal_events where y_date = " . $year ." and m_date = " . $month; if ( $rs = mysql_query($sql , $db ) ) { while ( $row = mysql_fetch_array($rs) ){ $out.= $row['d_date']. "=> array('?cal='" . $row['uid'] ."','linked-day')"; } $out.=$thisday . "=>array(NULL, NULL, '<span style=\"color: blue; font-face : arial; font-weight : bold; font-size : 12px; background : yellow;\">" . $thisday . "</span>')", return($out); } }[/pre] here is the array i'm trying to build: [pre]$days = array( 2=>array('?cal=2','linked-day'), 3=>array('?cal=3','linked-day'), 8=>array('?cal=4','linked-day'), 22=>array('?cal=5','linked-day'), $thisday=>array(NULL, NULL, '<span style="color: blue; font-face : arial; font-weight : bold; font-size : 12px; background : yellow;">' . $thisday . '</span>'), ); [/pre] here is the db table fields i'm querying: [pre]uid | y_date | m_date | d_date | title | entry [/pre] thanks in advance for the help Link to comment https://forums.phpfreaks.com/topic/91934-building-multi-element-array-from-mysql-database/ Share on other sites More sharing options...
craygo Posted February 19, 2008 Share Posted February 19, 2008 You don't add data to an array with .= should be $out[$row['d_date']] = array('?cal=' . $row['uid'], 'linked-day'); Ray Link to comment https://forums.phpfreaks.com/topic/91934-building-multi-element-array-from-mysql-database/#findComment-470822 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.