SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast Northern Star's Avatar
    Join Date
    Aug 2006
    Location
    Cheshire, UK
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Help needed with dynamic array() and a calendar function

    Hi all,

    I usually work with ASP but for this project I'm required to use php, so I'm having to 'learn on the job'. Basically i'm trying to create a calendar that links to events in a database.

    I've found the perfect calendar and i've sorted all my database stuff, but when I try and link the two it doesn't work - whats worse is I don't get any error messages to help me!

    Here's what i've got so far...

    $days is the variable that is passed to the calendar script, this is the 'static' code that works fine...

    Code:
    <?php
    
    $days = array(
         2=>array('/weblog/archive/2004/Jan/02','event'), 
         3=>array('/weblog/archive/2004/Jan/03','event'), 
    );
    ?>
    This is the loop I created to create the above list using a database to get all the relevant events...
    Code:
    $i=0;
    while ($i < $rCount) {
    					
    	$eID = mysql_result($result,$i,"eID");
    	$eStartDateTime = mysql_result($result,$i,"estartDateTime");
    	$eEndDateTime = mysql_result($result,$i,"eEndDateTime");
    					
    	list($sYear, $sMonth, $sDay) = split('-', $eStartDateTime);
    	$sDay = substr($sDay,0,2);
    					 
    	if ($thisYear == $year && $thisMonth == $month) {
    
                   $days .= "$sDay=>array('events-view.php?eID=$eID','event'),";
    
            }					 
    					  
    $i++;
    
    $days .= array($days);
    The calendar code i'm using can be found here...
    www.keithdevens.com/software/php_calendar

    I've been staring at this code for hours trying to figure out where I'm going wrong... I've a funny feeling i've got the wrong syntax or something or i'm missing a quote or something!

    Any help will be greatly appreciated!

    Thanks,

    Andy

  2. #2
    SitePoint Enthusiast Northern Star's Avatar
    Join Date
    Aug 2006
    Location
    Cheshire, UK
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Problem solved

    Ended up with this slight change. I think it didn't like it because I was trying to make the array out of a string? Anyhow, its fixed

    Code:
    if ($thisYear == $year && $thisMonth == $month) {
          if ($thisDay == $sDay) {
               $days[$sDay] = array('events-view.php?eID=$eID','today');
    	   $rToday = true;
          }
          else {
    	   $days[$sDay] = array('events-view.php?eID=$eID','event');
          }		
    }
    else {
        $days[$sDay] = array('events-view.php?eID=$eID','event');
    }

  3. #3
    SitePoint Zealot musher's Avatar
    Join Date
    Nov 2005
    Location
    Hull, England
    Posts
    161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $i=0;
    while (
    $i $rCount) {
                        
        
    $eID mysql_result($result,$i,"eID");
        
    $eStartDateTime mysql_result($result,$i,"estartDateTime");
        
    $eEndDateTime mysql_result($result,$i,"eEndDateTime");
                        
        list(
    $sYear$sMonth$sDay) = split('-'$eStartDateTime);
        
    $sDay substr($sDay,0,2);
                         
        if (
    $thisYear == $year && $thisMonth == $month) {

                   
    $days[$sDay]=array('events-view.php?eID=$eID','event');

            }                     
                          
    $i++; 
    is probably a little closer to what you need.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •