Jump to content

Event Calendar


silenthunter

Recommended Posts

<?php
$id = (int)$_GET['id'];
$months = array( 1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
if( !empty($_GET['month_name']) ){
$month_name = $_GET['month_name'];
} else {
$month_name = date("F");
}
$this_year = date("Y");
$today = date("d");
$month = date("m");
$event_day = date("j");
$this_month = $month_name .' '. $today .' '. $this_year;
$month_num = date("n", strtotime("$this_month"));
$first_day = date("w", strtotime("1 $month_name $this_year"));
$num_days = date("t", strtotime("1 $month_name $this_year"));
$prev_month = date("F", strtotime("$this_month -1 month"));
$next_month = date("F", strtotime("$this_month +1 month"));
?>

<?php
$query = "SELECT id, EXTRACT(DAY FROM date) FROM calendar WHERE (location={$_SESSION['location']} OR location=3) AND EXTRACT(MONTH FROM date)=$month AND EXTRACT(YEAR FROM date)=$this_year";
$result = mysql_query($query);
$num = mysql_num_rows($result);
if( $num > 0 ){
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
	$month_info[$row[1]] = $row[0];
	}
}
if( $month_info[$event_day] > 0 ){
echo "<DIV STYLE='position: absolute; top: 1px; left: -45px;'><A HREF='event_page.php?id=$month_info[$event_day]'><IMG SRC='images/today.gif' WIDTH='95' HEIGHT='57' BORDER='0'></A></DIV>";
}
?>

<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#000000"><TR><TD>
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="2" BGCOLOR="#000000">
<TR ALIGN="center" BGCOLOR="#C1C1FF"><TD COLSPAN="7"><FONT SIZE="1" COLOR="#000000" FACE="Verdana"><?php echo "$month_name $this_year"; ?></TD></TD></TR>
<TR ALIGN="center" BGCOLOR="#FFFFD5"><TD WIDTH="10"><FONT SIZE="1" COLOR="#000000" FACE="Verdana">S</TD>
<TD WIDTH="10"><FONT SIZE="1" COLOR="#000000" FACE="Verdana">M</TD>
<TD WIDTH="10"><FONT SIZE="1" COLOR="#000000" FACE="Verdana">T</TD>
<TD WIDTH="10"><FONT SIZE="1" COLOR="#000000" FACE="Verdana">W</TD>
<TD WIDTH="10"><FONT SIZE="1" COLOR="#000000" FACE="Verdana">T</TD>
<TD WIDTH="10"><FONT SIZE="1" COLOR="#000000" FACE="Verdana">F</TD>
<TD WIDTH="10"><FONT SIZE="1" COLOR="#000000" FACE="Verdana">S</TD></TR><TR ALIGN='center' BGCOLOR='#FFFFFF'>

<?php
for( $i=0; $i<=41; $i++ ) {
echo "<TD HEIGHT='10'";
if( $month_info[($i-$first_day+1)] > 0 ){
	if( ($i-$first_day+1) >= $event_day ){
		if( $location_info[($i-$first_day+1)] == 1 ){
			echo " BGCOLOR='#008000'";
			} else {
			echo " BGCOLOR='#0000FF'";
			}
		} else {
		echo " BGCOLOR='#FF8484'";
		}
	} elseif( $today == ($i-$first_day+1) ){
		echo " BGCOLOR='#BBFFFF'";
		}
echo "><FONT SIZE='1' COLOR='#000000' FACE='Arial'>";
if( $i < $first_day || $i >= ($first_day + $num_days) ){
	echo " ";
	} else {
	if( $month_info[($i-$first_day+1)] > 0 ){
		echo "<A HREF='event_page.php?id=". $month_info[($i-$first_day+1)];
		if( ($i-$first_day+1) >= $event_day ){
			echo "' STYLE='color: #FFFFB7;";
			} else {
			echo "' STYLE='color: #000000;";
		}
		echo " text-decoration: none;'>". ($i-$first_day+1) ."</A>";
		} else {
		echo ($i-$first_day+1);
		}
	}
echo "</FONT></TD>";
if( $i == 6 || $i ==13 || $i ==20 || $i ==27 || $i ==34 ){ echo "</TR><TR ALIGN='center' BGCOLOR='#FFFFFF'>"; }
}
echo "</TR></TABLE></TD></TR></TABLE></BODY></HTML>";
?>

 

 

You can try this one.  I use it as an include file and it will hi-light event days that you can link to another page to display the event details.

Your sql database uses columns:

 

id (auto_increment) || date || event_description || anything else you want

 

The id is the value extracted and passed on to the event page.

Tweat it out as you need :)

 

 

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.