Jump to content

Building multi-element array from mysql database


avantgardejazz@gmail.com

Recommended Posts

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

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.