Jump to content

Building multi-element array from mysql database


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

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.