Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 296
  • Last Modified:

PHP Calendar with events

I have the following code where it writes out a calendar and I can do next, previous etc.
I am having trouble getting the dates to populate on the correct dates.

How it is now, all events show up on today's date...


<?php
 
$nextm=$_GET['month'];
$nexty=$_GET['year'];
 

require_once("includes/db_login.inc");
 
if($nextm == "13")
{
        $nextm=1;
        $nexty++;
}
 
if($nextm == "0")
{
        $nextm=12;
        $nexty--;
}
 
//This gets today's date
$date =time () ;
 
//This puts the day, month, and year in seperate variables
$day = date('d', $date) ;
 
If ($nextm != ""){
        $month=$nextm;
        
}
else{
$month = date('m', $date) ;
 
}
$month2  = date('m', $date);
$minmonth=$month-1;
$maxmonth=$month+1;
If ($nexty != "") {
        $year=$nexty;
}
else{
$year = date('Y', $date) ;
}
$year2 = date('Y', $date) ;
//Here we generate the first day of the month
$first_day = mktime(0,0,0,$month, 1, $year) ;
 
//This gets us the month name
$title = date('F', $first_day) ; 
//Here we find out what day of the week the first day of the month falls on
$day_of_week = date('D', $first_day) ;
 
//Once we know what day of the week it falls on, we know how many blank days occure before it. If the first day of the week is a Sunday then it would be zero
switch($day_of_week){
case "Sun": $blank = 0; break;
case "Mon": $blank = 1; break;
case "Tue": $blank = 2; break;
case "Wed": $blank = 3; break;
case "Thu": $blank = 4; break;
case "Fri": $blank = 5; break;
case "Sat": $blank = 6; break;
}
 
//We then determine how many days are in the current month
$days_in_month = cal_days_in_month(0, $month, $year) ; 
//Here we start building the table heads
echo "<table  border=2 class=table width=100% height=80%>";
echo "<tr><th class=head colspan=7> <a href=calendar2.php?month=$minmonth&year=$year><<</a>   $title $year <a href=calendar2.php?month=$maxmonth&year=$year>>></a>   </th></tr>";
echo "<tr class=body><td width=42>S</td><td width=42>M</td><td width=42>T</td><td width=42>W</td><td width=42>T</td><td width=42>F</td><td width=42>S</td></tr>";
 
//This counts the days in the week, up to 7
$day_count = 1;
 
echo "<tr>";
//first we take care of those blank days
while ( $blank > 0 )
{
echo "<td> </td>";
$blank = $blank-1;
$day_count++;
} 
//sets the first day of the month to 1
$day_num = 1;
 
//count up the days, untill we've done all of them in the month
 
//while ($row = mysql_fetch_array($res))
//{
// while ($row2 = mysql_fetch_array($res2))
// {    
	while ( $day_num <= $days_in_month )
	{
      	if ($day==$day_num and $year2==$year and $month2==$month) // so this is today
		{
                
            ?><td class=day2><? echo "$day_num <br />";
 
 
        	$resl = "select * from Events";
    		$res=mysql_query($resl) or die(mysql_error());
		$row = mysql_fetch_array($res);
        	
		$resl2 = "select * from Events WHERE StartDate = $day_num"; 
     		$res2=mysql_query($resl2) or die(mysql_error());
		$row2 = mysql_fetch_array($res2);
  while ($row = mysql_fetch_assoc($res))
      
	    {
                
  $event_id = $row['ID'];
                $event_name = $row['Event'];
                $event_date = $row['StartDate'];
	       		$event_time = mysql2timestamp($event_date);
                $event_display_date = date("D, F j, Y", $event_time);
                $event_description = $row['LocationID'];
                $curDate = getdate($event_time);
                $curMonth = $curDate['mon'];
                $curYear = $curDate['year'];
                $curFullMonth = $curDate['month'];
 
 echo "$event_name\n";
 }
		?> 
		
		
		</td><?
		
		}
        	else
		{
 
        	$resl = "select * from Events  WHERE StartDate = $day_num";
    		$res=mysql_query($resl) or die(mysql_error());
		$row = mysql_fetch_array($res);
        	
		$resl2 = "select * from Events WHERE StartDate = $day_num"; 
     		$res2=mysql_query($resl2) or die(mysql_error());
		$row2 = mysql_fetch_array($res2);
                
?><td class=day> <? echo "$day_num";?> </td><?
        
        }
$day_num++;
$day_count++;
 
//Make sure we start a new row every week
if ($day_count > 7)
{
echo "</tr><tr>";
$day_count = 1;
}
} 
//    }
//    }
    
//Finaly we finish out the table with some blank details if needed
while ( $day_count >1 && $day_count <=7 )
{
echo "<td>  </td>";
$day_count++;
}
 
echo "</tr></table>"; 

 

 ?>

Open in new window

0
katlees
Asked:
katlees
  • 9
  • 8
  • 2
  • +1
1 Solution
 
FrozeniceCommented:
this is where jquery comes in handy.


http://jqueryui.com/demos/datepicker/


:)


br
0
 
Lukasz ChmielewskiCommented:
Can you post the mysql2timestamp function ?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Lukasz ChmielewskiCommented:
I don't think you need to check if each day is the current one. But check this code:

<?php
 
$nextm=$_GET['month'];
$nexty=$_GET['year'];
 

require_once("includes/db_login.inc");
 
if($nextm == "13")
{
        $nextm=1;
        $nexty++;
}
 
if($nextm == "0")
{
        $nextm=12;
        $nexty--;
}
 
//This gets today's date
$date =time () ;
 
//This puts the day, month, and year in seperate variables
$day = date('d', $date) ;
 
If ($nextm != ""){
        $month=$nextm;
        
}
else{
$month = date('m', $date) ;
 
}
$month2  = date('m', $date);
$minmonth=$month-1;
$maxmonth=$month+1;
If ($nexty != "") {
        $year=$nexty;
}
else{
$year = date('Y', $date) ;
}
$year2 = date('Y', $date) ;
//Here we generate the first day of the month
$first_day = mktime(0,0,0,$month, 1, $year) ;
 
//This gets us the month name
$title = date('F', $first_day) ; 
//Here we find out what day of the week the first day of the month falls on
$day_of_week = date('D', $first_day) ;
 
//Once we know what day of the week it falls on, we know how many blank days occure before it. If the first day of the week is a Sunday then it would be zero
switch($day_of_week){
case "Sun": $blank = 0; break;
case "Mon": $blank = 1; break;
case "Tue": $blank = 2; break;
case "Wed": $blank = 3; break;
case "Thu": $blank = 4; break;
case "Fri": $blank = 5; break;
case "Sat": $blank = 6; break;
}
 
//We then determine how many days are in the current month
$days_in_month = cal_days_in_month(0, $month, $year) ; 
//Here we start building the table heads
echo "<table  border=2 class=table width=100% height=80%>";
echo "<tr><th class=head colspan=7> <a href=calendar2.php?month=$minmonth&year=$year><<</a>   $title $year <a href=calendar2.php?month=$maxmonth&year=$year>>></a>   </th></tr>";
echo "<tr class=body><td width=42>S</td><td width=42>M</td><td width=42>T</td><td width=42>W</td><td width=42>T</td><td width=42>F</td><td width=42>S</td></tr>";
 
//This counts the days in the week, up to 7
$day_count = 1;
 
echo "<tr>";
//first we take care of those blank days
while ( $blank > 0 )
{
echo "<td> </td>";
$blank = $blank-1;
$day_count++;
} 
//sets the first day of the month to 1
$day_num = 1;
 
//count up the days, untill we've done all of them in the month
 
//while ($row = mysql_fetch_array($res))
//{
// while ($row2 = mysql_fetch_array($res2))
// {    
	while ( $day_num <= $days_in_month )
	{
      	if ($day==$day_num and $year2==$year and $month2==$month) // so this is today
		{
                
            ?><td class=day2><? echo "$day_num <br />";
 
 
        	$resl = "select * from Events";
    		$res=mysql_query($resl) or die(mysql_error());
		$row = mysql_fetch_array($res);
        	
		$resl2 = "select * from Events WHERE StartDate = $day_num"; 
     		$res2=mysql_query($resl2) or die(mysql_error());
		$row2 = mysql_fetch_array($res2);
  while ($row = mysql_fetch_assoc($res))
      
	    {
                
  $event_id = $row['ID'];
                $event_name = $row['Event'];
                $event_date = $row['StartDate'];
	       		$event_time = mysql2timestamp($event_date);
                $event_display_date = date("D, F j, Y", $event_time);
                $event_description = $row['LocationID'];
                $curDate = getdate($event_time);
                $curMonth = $curDate['mon'];
                $curYear = $curDate['year'];
                $curFullMonth = $curDate['month'];
 
 echo "$event_name\n";
 }
		?> 
		
		
		</td><?
		
		}
        	else
		{
        
        $thisday = mktime(0,0,0,$month, $day_num, $year);
        $dd = date ("Y-m-d",$thisday); 
       	
		$resl2 = "select * from Events WHERE SUBSTR(StartDate FROM 1 FOR 10) = '$dd'"; 
     	$res2=mysql_query($resl2) or die(mysql_error());
		$row2 = mysql_fetch_array($res2);
		
		$event_name2 = $row2['Event'];
	    //$event_time2 = mysql2timestamp($event_date2);
        //$event_display_date2 = date("D, F j, Y", $event_time2);
                
?><td class=day><? echo "$day_num\n"; echo "$event_name2\n ";?> </td><?
        
        }
$day_num++;
$day_count++;
 
//Make sure we start a new row every week
if ($day_count > 7)
{
echo "</tr><tr>";
$day_count = 1;
}
} 
//    }
//    }
    
//Finaly we finish out the table with some blank details if needed
while ( $day_count >1 && $day_count <=7 )
{
echo "<td>  </td>";
$day_count++;
}
 
echo "</tr></table>"; 

 

 ?>

Open in new window

0
 
Ray PaseurCommented:
Some information on DATETIME processing is available here.  One of the examples includes some design patterns for a calendar.  HTH, ~Ray
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html
0
 
katleesAuthor Commented:
Roads_Roads - yours works good except:
1) It shows all the events on todays date
2) It doesn't show multiple events on a day - only the first one.
0
 
Ray PaseurCommented:
Make a Google search for this string, "Example of PHP and MySQL Web Calendar" and also look at the jQuery date picker scripts.  There are many good examples in addition to the principles illustrated in the article linked here.
0
 
Lukasz ChmielewskiCommented:
From line 137 to 143 - switch to this for the multiple events shown on the day

<td class=day>
<? echo "$day_num\n";

while($row2 = mysql_fetch_array($res2)){
   $event_name2 = $row2['Event'];
}            

?> </td>
0
 
katleesAuthor Commented:
are you sure your row numbers are right Roads?
0
 
Lukasz ChmielewskiCommented:
ok, so from 129 (the "else " part regarding the days that are different that this day) should be

else{
 $thisday = mktime(0,0,0,$month, $day_num, $year);
 $dd = date ("Y-m-d",$thisday); 
       	
 $resl2 = "select * from Events WHERE SUBSTR(StartDate FROM 1 FOR 10) = '$dd'"; 
 $res2=mysql_query($resl2) or die(mysql_error());
 ?>
 <td class=day>
 <? echo "$day_num\n"; 
 while($row2 = mysql_fetch_array($res2)){
    $event_name2 = $row2['Event'];
 }            
?> 
</td>
<?
}

Open in new window

0
 
katleesAuthor Commented:
Maybe I"m missing something, but when I do that, I get all the events looped on today's date.. no other events show up... My whole code is below...
Each day should loop through the events on that day...
<?php
 
$nextm=$_GET['month'];
$nexty=$_GET['year'];
 

require_once("includes/db_login.inc");
 
if($nextm == "13")
{
        $nextm=1;
        $nexty++;
}
 
if($nextm == "0")
{
        $nextm=12;
        $nexty--;
}
 
//This gets today's date
$date =time () ;
 
//This puts the day, month, and year in seperate variables
$day = date('d', $date) ;
 
If ($nextm != ""){
        $month=$nextm;
        
}
else{
$month = date('m', $date) ;
 
}
$month2  = date('m', $date);
$minmonth=$month-1;
$maxmonth=$month+1;
If ($nexty != "") {
        $year=$nexty;
}
else{
$year = date('Y', $date) ;
}
$year2 = date('Y', $date) ;
//Here we generate the first day of the month
$first_day = mktime(0,0,0,$month, 1, $year) ;
 
//This gets us the month name
$title = date('F', $first_day) ; 
//Here we find out what day of the week the first day of the month falls on
$day_of_week = date('D', $first_day) ;
 
//Once we know what day of the week it falls on, we know how many blank days occure before it. If the first day of the week is a Sunday then it would be zero
switch($day_of_week){
case "Sun": $blank = 0; break;
case "Mon": $blank = 1; break;
case "Tue": $blank = 2; break;
case "Wed": $blank = 3; break;
case "Thu": $blank = 4; break;
case "Fri": $blank = 5; break;
case "Sat": $blank = 6; break;
}
 
//We then determine how many days are in the current month
$days_in_month = cal_days_in_month(0, $month, $year) ; 
//Here we start building the table heads
echo "<table  border=2 class=table width=100% height=80%>";
echo "<tr><th class=head colspan=7> <a href=calendar2.php?month=$minmonth&year=$year><<</a>   $title $year <a href=calendar2.php?month=$maxmonth&year=$year>>></a>   </th></tr>";
echo "<tr class=body><td width=42>S</td><td width=42>M</td><td width=42>T</td><td width=42>W</td><td width=42>T</td><td width=42>F</td><td width=42>S</td></tr>";
 
//This counts the days in the week, up to 7
$day_count = 1;
 
echo "<tr>";
//first we take care of those blank days
while ( $blank > 0 )
{
echo "<td> </td>";
$blank = $blank-1;
$day_count++;
} 
//sets the first day of the month to 1
$day_num = 1;
 
//count up the days, untill we've done all of them in the month
 
//while ($row = mysql_fetch_array($res))
//{
// while ($row2 = mysql_fetch_array($res2))
// {    
	while ( $day_num <= $days_in_month )
	{
      	if ($day==$day_num and $year2==$year and $month2==$month) // so this is today
		{
                
            ?><td class=day2 bgcolor="#FF0000"><? echo "$day_num <br />$event_name";
 
 
        	$resl = "select * from Events";
    		$res=mysql_query($resl) or die(mysql_error());
		$row = mysql_fetch_array($res);
        	
		$resl2 = "select * from Events WHERE StartDate = $day_num"; 
     		$res2=mysql_query($resl2) or die(mysql_error());
		$row2 = mysql_fetch_array($res2);
  while ($row = mysql_fetch_assoc($res))
      
	    {
                
  $event_id = $row['ID'];
                $event_name = $row['Event'];
                $event_date = $row['StartDate'];
	       		$event_time = mysql2timestamp($event_date);
                $event_display_date = date("D, F j, Y", $event_time);
                $event_description = $row['LocationID'];
                $curDate = getdate($event_time);
                $curMonth = $curDate['mon'];
                $curYear = $curDate['year'];
                $curFullMonth = $curDate['month'];
 
 echo "$event_name\n";
 }
		?> 
		
		
		</td>


		<?
		
		}
       else{
 $thisday = mktime(0,0,0,$month, $day_num, $year);
 $dd = date ("Y-m-d",$thisday); 
       	
 $resl2 = "select * from Events WHERE SUBSTR(StartDate FROM 1 FOR 10) = '$dd'"; 
 $res2=mysql_query($resl2) or die(mysql_error());
 ?>
 <td class=day>
 <? echo "$day_num\n"; 
 while($row2 = mysql_fetch_array($res2)){
    $event_name2 = $row2['Event'];
 }            
?> 
</td>
<?
} 

$day_num++;
$day_count++;
 
//Make sure we start a new row every week
if ($day_count > 7)
{
echo "</tr><tr>";
$day_count = 1;
}
} 
//    }
//    }
    
//Finaly we finish out the table with some blank details if needed
while ( $day_count >1 && $day_count <=7 )
{
echo "<td>  </td>";
$day_count++;
}
 
echo "</tr></table>"; 

 

 ?>

Open in new window

0
 
Lukasz ChmielewskiCommented:
Does this make any change ?

<?php
 
$nextm=$_GET['month'];
$nexty=$_GET['year'];
 

require_once("includes/db_login.inc");
 
if($nextm == "13")
{
        $nextm=1;
        $nexty++;
}
 
if($nextm == "0")
{
        $nextm=12;
        $nexty--;
}
 
//This gets today's date
$date =time () ;
 
//This puts the day, month, and year in seperate variables
$day = date('d', $date) ;
 
If ($nextm != ""){
        $month=$nextm;
        
}
else{
$month = date('m', $date) ;
 
}
$month2  = date('m', $date);
$minmonth=$month-1;
$maxmonth=$month+1;
If ($nexty != "") {
        $year=$nexty;
}
else{
$year = date('Y', $date) ;
}
$year2 = date('Y', $date) ;
//Here we generate the first day of the month
$first_day = mktime(0,0,0,$month, 1, $year) ;
 
//This gets us the month name
$title = date('F', $first_day) ; 
//Here we find out what day of the week the first day of the month falls on
$day_of_week = date('D', $first_day) ;
 
//Once we know what day of the week it falls on, we know how many blank days occure before it. If the first day of the week is a Sunday then it would be zero
switch($day_of_week){
case "Sun": $blank = 0; break;
case "Mon": $blank = 1; break;
case "Tue": $blank = 2; break;
case "Wed": $blank = 3; break;
case "Thu": $blank = 4; break;
case "Fri": $blank = 5; break;
case "Sat": $blank = 6; break;
}
 
//We then determine how many days are in the current month
$days_in_month = cal_days_in_month(0, $month, $year) ; 
//Here we start building the table heads
echo "<table  border=2 class=table width=100% height=80%>";
echo "<tr><th class=head colspan=7> <a href=calendar2.php?month=$minmonth&year=$year><<</a>   $title $year <a href=calendar2.php?month=$maxmonth&year=$year>>></a>   </th></tr>";
echo "<tr class=body><td width=42>S</td><td width=42>M</td><td width=42>T</td><td width=42>W</td><td width=42>T</td><td width=42>F</td><td width=42>S</td></tr>";
 
//This counts the days in the week, up to 7
$day_count = 1;
 
echo "<tr>";
//first we take care of those blank days
while ( $blank > 0 )
{
echo "<td> </td>";
$blank = $blank-1;
$day_count++;
} 
//sets the first day of the month to 1
$day_num = 1;
 
//count up the days, untill we've done all of them in the month
 
//while ($row = mysql_fetch_array($res))
//{
// while ($row2 = mysql_fetch_array($res2))
// {    
	while ( $day_num <= $days_in_month )
	{
      	if ($day==$day_num and $year2==$year and $month2==$month) // so this is today
		{
                
            ?><td class=day2 bgcolor="#FF0000"><? echo "$day_num <br />";
 
 
        	$resl = "select * from Events";
    		$res=mysql_query($resl) or die(mysql_error());
		$row = mysql_fetch_array($res);
        	
		$resl2 = "select * from Events WHERE StartDate = $day_num"; 
     		$res2=mysql_query($resl2) or die(mysql_error());
		$row2 = mysql_fetch_array($res2);
  while ($row = mysql_fetch_assoc($res))
      
	    {
                
  $event_id = $row['ID'];
                $event_name = $row['Event'];
                $event_date = $row['StartDate'];
	       		$event_time = mysql2timestamp($event_date);
                $event_display_date = date("D, F j, Y", $event_time);
                $event_description = $row['LocationID'];
                $curDate = getdate($event_time);
                $curMonth = $curDate['mon'];
                $curYear = $curDate['year'];
                $curFullMonth = $curDate['month'];
 
 echo "$event_name\n";
 }
		?> 
		
		
		</td>


		<?
		
		}
       else{
 $thisday = mktime(0,0,0,$month, $day_num, $year);
 $dd = date ("Y-m-d",$thisday); 
       	
 $resl2 = "select * from Events WHERE SUBSTR(StartDate FROM 1 FOR 10) = '$dd'"; 
 $res2=mysql_query($resl2) or die(mysql_error());
 ?>
 <td class=day>
 <? echo "$day_num\n"; 
 while($row2 = mysql_fetch_array($res2)){
    $event_name2 = $row2['Event'];
    echo"$event_name2<br />";
 }            
?> 
</td>
<?
} 

$day_num++;
$day_count++;
 
//Make sure we start a new row every week
if ($day_count > 7)
{
echo "</tr><tr>";
$day_count = 1;
}
} 
//    }
//    }
    
//Finaly we finish out the table with some blank details if needed
while ( $day_count >1 && $day_count <=7 )
{
echo "<td>  </td>";
$day_count++;
}
 
echo "</tr></table>"; 

 

 ?>

Open in new window

0
 
katleesAuthor Commented:
It puts the events on their date but puts ALL events on today's date
0
 
Lukasz ChmielewskiCommented:
OK, give me a sec.
0
 
Lukasz ChmielewskiCommented:
And this: ?

<?php
 
$nextm=$_GET['month'];
$nexty=$_GET['year'];
 

require_once("includes/db_login.inc");
 
if($nextm == "13")
{
        $nextm=1;
        $nexty++;
}
 
if($nextm == "0")
{
        $nextm=12;
        $nexty--;
}
 
//This gets today's date
$date =time () ;
 
//This puts the day, month, and year in seperate variables
$day = date('d', $date) ;
 
If ($nextm != ""){
        $month=$nextm;
        
}
else{
$month = date('m', $date) ;
 
}
$month2  = date('m', $date);
$minmonth=$month-1;
$maxmonth=$month+1;
If ($nexty != "") {
        $year=$nexty;
}
else{
$year = date('Y', $date) ;
}
$year2 = date('Y', $date) ;
//Here we generate the first day of the month
$first_day = mktime(0,0,0,$month, 1, $year) ;
 
//This gets us the month name
$title = date('F', $first_day) ; 
//Here we find out what day of the week the first day of the month falls on
$day_of_week = date('D', $first_day) ;
 
//Once we know what day of the week it falls on, we know how many blank days occure before it. If the first day of the week is a Sunday then it would be zero
switch($day_of_week){
case "Sun": $blank = 0; break;
case "Mon": $blank = 1; break;
case "Tue": $blank = 2; break;
case "Wed": $blank = 3; break;
case "Thu": $blank = 4; break;
case "Fri": $blank = 5; break;
case "Sat": $blank = 6; break;
}
 
//We then determine how many days are in the current month
$days_in_month = cal_days_in_month(0, $month, $year) ; 
//Here we start building the table heads
echo "<table  border=2 class=table width=100% height=80%>";
echo "<tr><th class=head colspan=7> <a href=calendar2.php?month=$minmonth&year=$year><<</a>   $title $year <a href=calendar2.php?month=$maxmonth&year=$year>>></a>   </th></tr>";
echo "<tr class=body><td width=42>S</td><td width=42>M</td><td width=42>T</td><td width=42>W</td><td width=42>T</td><td width=42>F</td><td width=42>S</td></tr>";
 
//This counts the days in the week, up to 7
$day_count = 1;
 
echo "<tr>";
//first we take care of those blank days
while ( $blank > 0 )
{
echo "<td> </td>";
$blank = $blank-1;
$day_count++;
} 
//sets the first day of the month to 1
$day_num = 1;
 
//count up the days, untill we've done all of them in the month
 
//while ($row = mysql_fetch_array($res))
//{
// while ($row2 = mysql_fetch_array($res2))
// {    
	while ( $day_num <= $days_in_month )
	{
      	if ($day==$day_num and $year2==$year and $month2==$month) // so this is today
		{
                
            ?><td class=day2 bgcolor="#FF0000"><? echo "$day_num <br />";
 
 
        	$resl = "select * from Events";
    		$res=mysql_query($resl) or die(mysql_error());
            $row = mysql_fetch_array($res);
        
        
            $thisday = mktime(0,0,0,$month, $day_num, $year);
            $dd = date ("Y-m-d",$thisday); 
       	
            $resl2 = "select * from Events WHERE SUBSTR(StartDate FROM 1 FOR 10) = '$dd'";         
        	
     		$res2=mysql_query($resl2) or die(mysql_error());
            while ($row = mysql_fetch_assoc($res2)){
	    
                
            $event_id = $row['ID'];
                            $event_name = $row['Event'];
                            $event_date = $row['StartDate'];
                            $event_time = mysql2timestamp($event_date);
                            $event_display_date = date("D, F j, Y", $event_time);
                            $event_description = $row['LocationID'];
                            $curDate = getdate($event_time);
                            $curMonth = $curDate['mon'];
                            $curYear = $curDate['year'];
                            $curFullMonth = $curDate['month'];
             
             echo "$event_name<br />";
             }
		?> 
		
		
		</td>


		<?
		
		}
        else{
            $thisday = mktime(0,0,0,$month, $day_num, $year);
            $dd = date ("Y-m-d",$thisday); 
       	
            $resl2 = "select * from Events WHERE SUBSTR(StartDate FROM 1 FOR 10) = '$dd'"; 
            $res2=mysql_query($resl2) or die(mysql_error());
        ?>
        <td class=day>
        <? echo "$day_num\n"; 
        while($row2 = mysql_fetch_array($res2)){
            $event_name2 = $row2['Event'];
            echo"$event_name2<br />";
            }            
        ?> 
        </td>
        <?
        } 

$day_num++;
$day_count++;
 
//Make sure we start a new row every week
if ($day_count > 7)
{
echo "</tr><tr>";
$day_count = 1;
}
} 
//    }
//    }
    
//Finaly we finish out the table with some blank details if needed
while ( $day_count >1 && $day_count <=7 )
{
echo "<td>  </td>";
$day_count++;
}
 
echo "</tr></table>"; 

 

 ?>

Open in new window

0
 
katleesAuthor Commented:
That looks like it worked.... Yeah! Thanks.
0
 
Lukasz ChmielewskiCommented:
Thank you. This code requires some cleaning up anyway :P
0
 
katleesAuthor Commented:
Roads - can you help with one more thing - the events are coming off all days before today... how do I keep the calendar populated?
0
 
katleesAuthor Commented:
nevermind... I was wrong.
0
 
Lukasz ChmielewskiCommented:
Sure ? Feel free to post - I'll try to help.
0
 
katleesAuthor Commented:
Roads_roads - I posted another question to turn this calendar to a weekly view instead of monthly.. can you help? I dont' want to start over with the code.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_26987449.html
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 9
  • 8
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now