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.

118 Comments to "Event Calendar"

Red X August 19, 2015 at 4:12 pm | Reply


Hi, I want to know how can I use the event properties..if someone can help me....thanks a lot!
Red X August 19, 2015 at 4:43 pm


And i want to know if I can to create a calendar event dynamic...for every user personal..a calendar private..not for all users..for example...John create his personal event...Marry create her personal event...and the list continue..
Paul raj July 28, 2015 at 7:32 am | Reply


Hi , friends good morning Am Paul raj please help me , urgent
I want a calender source code in php. then i need to validate like the date is acailable is green colour if is not available shown red colour. anyone know my requirement please send me fast
vaidyamanishjoshi July 28, 2015 at 7:50 am


open calendar.css file...
and Edit following....

around line number 45 -
#Calendar .withevent { background-color:green;}

around line number 53 -
#Calendar .noevent { background-color:red;}
vaidyamanishjoshi July 22, 2015 at 10:03 am | Reply


Can we disable all Dates prior to current date in this script?
saroar mamun June 7, 2015 at 6:55 pm | Reply


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


Event does not show when I navigate calender. First time it load but after that
return nothing please help.
hisham April 26, 2015 at 6:25 am | Reply


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]<>'') {
$click = "onmouseover=\"LoadEvents('".$cYear."-".$cMonth."-".$current_day."')\"";

} else {
$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


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


hello guys I need help on this I wsa trying to code a little script like this 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


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


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


$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
$cMonth = "0".intval($_REQUEST["month"]);
if ($_REQUEST["month"]>9) {
$cMonth = intval($_REQUEST["month"]);
$cYear = intval($_REQUEST["year"]);
$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%">
<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>
<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>
$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]<>'') {
$click = "onclick=\"LoadEvents('".$cYear."-".$cMonth."-".$current_day."')\"";
} else {
$click = '';

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

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

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


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.

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 ~