GeekyCorner

MySQL Table Search »

Event Calendar

Price: FREE Version: 1.0
The Event Calendar script is a free piece of PHP code to create an event calendar for you. Below is a description of the files used and what each one of them does.

calendar.css - external CSS file which lets you easily change the appearance. If you do not know how to locate the styles used for each calendar element please refer to "Inspect CSS styles using Chrome" video found here

calendar.js - all the JS functions used to scroll the calendar and the ajax calls made to load both the calendar and the events

calendar.php - this is the PHP script used to build and print the calendar widget

config.php - the file where mysql database login is defined

database.sql - mysql table structure

events.php - this is the PHP file which loads the events once you click on a date

example-page.html - a sample web page with embed calendar widget.

112 Comments to "Event Calendar"

saroar mamun June 7, 2015 at 6:55 pm | Reply

0

Nice and very helpful script !
Sazzad May 16, 2015 at 9:07 am | Reply

+2

Event does not show when I navigate calender. First time it load but after that
$events[$cYear."-".$cMonth."-".$current_day]
return nothing please help.
hisham April 26, 2015 at 6:25 am | Reply

0

hy all!! i have brought some changes to this awesome calender..can some please help me with this, i would like to have popover function when withevent is hovered.. please help..

// set css class name based on number of events for that day
if ($events[$cYear."-".$cMonth."-".$current_day]<>'') {
$css='withevent';
$click = "onmouseover=\"LoadEvents('".$cYear."-".$cMonth."-".$current_day."')\"";



} else {
$css='noevent';
$click = "onmouseout=\"LoadEvents('')\"";
}

echo "<td class='".$css."'".$click.">". $current_day . "</td>";

if (($i % 7) == 6 ) echo "</tr>";
}
guru April 20, 2015 at 9:46 am | Reply

+1

hey it worked good to show only the calender, but not the events..pls help me
tajuboy April 14, 2015 at 3:52 pm | Reply

0

hello guys I need help on this I wsa trying to code a little script like this http://www.marsleisure.com/result.php dat will be showing weekend match pool result from week 1 - 52 I try recode this event calendar but still to no avail becuase am still a novice on javascript and I even try to change the de month to season with also the days to weeks
i:e de month willl be the seasons while de day will be de week 1-52

please try and help me code it I need it for ma project work
vaidyamanishjoshi April 11, 2015 at 1:06 pm | Reply

0

thanx for nice code.

currently it is showing current month. But I want to show the upcoming month in which the event is scheduled.

e.g. current month is April 2015 and No event is scheduled in this month. But next event is in May 2015 then in July 2015. Now I want to show May 2015 calendar by default till Event Date and then after to show July 2015 which contain event and not June 2015 bydefault.

How to achieve it in this script ?
vaidyamanishjoshi April 12, 2015 at 11:39 am

+5

I have found Solution To Show The upcoming month in which event is scheduled (if current month have no event)....Hope this will be helpful for others too...


<?
date_default_timezone_set('Asia/kolkata');

error_reporting(0);
include("config.php");
$ceYear=date("Y");
$ceMonth=date("m");
$sqlevent = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE YEAR(`event_date`) >= ".$ceYear." AND MONTH(`event_date`) >= ".$ceMonth." ";
$sql_resultevent = mysql_query ($sqlevent, $connection ) or die ('request "Could not execute SQL query" '.$sqlevent);
$rowevent = mysql_fetch_array($sql_resultevent);
/// get current month and year and store them in $cMonth and $cYear variables
if($_REQUEST["month"]>0){
$cMonth = "0".intval($_REQUEST["month"]);
if ($_REQUEST["month"]>9) {
$cMonth = intval($_REQUEST["month"]);
}
$cYear = intval($_REQUEST["year"]);
}else
{
$cMonth = date("m", strtotime($rowevent["event_date"]));
$cYear = date("Y", strtotime($rowevent["event_date"]));
}

// generate an array with all dates with events
$sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE YEAR(`event_date`) >= ".$cYear." AND MONTH(`event_date`) >= ".$cMonth." ";
$sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql);
while ($row = mysql_fetch_assoc($sql_result)) {
$events[$row["event_date"]]["title"] = $row["title"];
$events[$row["event_date"]]["description"] = $row["description"];
}

// calculate next and prev month and year used for next / prev month navigation links and store them in respective variables
$prev_year = $cYear;
$next_year = $cYear;
$prev_month = intval($cMonth)-1;
$next_month = intval($cMonth)+1;

// if current month is December or January month navigation links have to be updated to point to next / prev years
if ($cMonth == 12 ) {
$next_month = 1;
$next_year = $cYear + 1;
} elseif ($cMonth == 1 ) {
$prev_month = 12;
$prev_year = $cYear - 1;
}

if ($prev_month<10) $prev_month = '0'.$prev_month;
if ($next_month<10) $next_month = '0'.$next_month;
?>
<table width="100%">
<tr>
<td class="mNav"><a href="javascript:LoadMonth('<?php echo $prev_month; ?>', '<?php echo $prev_year; ?>')"><<</a></td>
<td colspan="5" class="cMonth"><?php echo date("F, Y",strtotime($cYear."-".$cMonth."-01")); ?></td>
<td class="mNav"><a href="javascript:LoadMonth('<?php echo $next_month; ?>', '<?php echo $next_year; ?>')">>></a></td>
</tr>
<tr>
<td class="wDays" style="background-color:#c90404; color:#FFFFFF;">Sun</td>
<td class="wDays">Mon</td>
<td class="wDays">Tue</td>
<td class="wDays">Wed</td>
<td class="wDays">Thu</td>
<td class="wDays">Fri</td>
<td class="wDays">Sat</td>
</tr>
<?php
$first_day_timestamp = mktime(0,0,0,$cMonth,1,$cYear); // time stamp for first day of the month used to calculate
$maxday = date("t",$first_day_timestamp); // number of days in current month
$thismonth = getdate($first_day_timestamp); // find out which day of the week the first date of the month is
$startday = $thismonth['wday'] ; // 0 is for Sunday and as we want week to start on Mon we subtract 1

for ($i=0; $i<($maxday+$startday); $i++) {

if (($i % 7) == 0 ) echo "<tr>";

if ($i < $startday) { echo "<td> </td>"; continue; };

$current_day = $i - $startday + 1;
if ($current_day<10) $current_day = '0'.$current_day;

// set css class name based on number of events for that day
if ($events[$cYear."-".$cMonth."-".$current_day]<>'') {
$css='withevent';
$click = "onclick=\"LoadEvents('".$cYear."-".$cMonth."-".$current_day."')\"";
} else {
$css='noevent';
$click = '';
}

echo "<td class='".$css."'".$click.">". $current_day . "</td>";

if (($i % 7) == 6 ) echo "</tr>";
}
?>
</table>

Ime April 6, 2015 at 8:33 am | Reply

+1

First of all, thank you for your great calnedar script.
Iz exactly what I needed.

I have one question.
How to show this calendar on oage that is not in the same folder as calendar files (calendar.php, calendar,js, calendar.css and events.php)?

For now, i have managed to show calendar on myPage.php as long as it is in the same folder as calendar files using

<div id="Calendar" src="calendar.php"> </div>
<div id="Events" src="events.php"> </div>
<script language="javascript" src="calendar.js"></script>


I would like to place those files in root/calendar folder and to use them on other pages on my web server.

I would be wery grateful if you can help me with this since I have spend all week trying to make this work.

Thank you.
Mona April 4, 2015 at 2:42 am | Reply

0

This calendar isn't displaying for me at all even though I connected it to my database and important the sql data onto my database....HELP!!!
Ime April 6, 2015 at 8:41 am

0

Check dates of your events in database. They are dated 2013 so you can't see them untill you show year 2013.
Add new events with current date thru phpMyAdmin, table event_calendar.
nam April 2, 2015 at 3:41 pm | Reply

0

hey, can you plz show da code to view the event title and description in pop-up.
sithira March 30, 2015 at 3:57 pm | Reply

+1

i have this script modified to use with mysqli and with some new features .. All the bugs in the original script have been fixed and some new features have been added too . contact me if you need my script (y)
pieter March 31, 2015 at 2:27 pm

0

can you upload de fixed files?
Kent Bogestav April 14, 2015 at 8:48 am

0

Can you pls. send me the updated code?

//Kent


Please be polite and helpful and do not spam or offend others. We promise you will be treated the same way.

Log in your free account or if you still haven't joined you can create your free account now.

Posting tip:
if you use code in your comments please put it in these tags [php], [sql], [css], [js]
PHP code example: [php] echo date("Y-m-d"); [/php]

Thank you,
~ PHPJabbers team ~