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.

64 Comments to "Event Calendar"

Kenny September 16, 2014 at 7:32 pm | Reply

0

hi.,.can anyone help me about this, i want to highlight also the current date.,.how can i do that?
Streak September 16, 2014 at 5:44 pm | Reply

0

Is it Possible to Highlight the Current Day? ex. if the today is 9/16/2014. the 16 in the calendar is highlighted. TIA
Sparky September 16, 2014 at 11:12 pm

+1

One thing to keep in mind, is if you highlight the current date with a background color like the event days, and there is an event on the current day, it would highlight as a current day, not current day AND event. A few simple changes there... but 20 minutes later, here is the 'Current Day' highlight code... (I have make a LOT of changes to the original code, so I hope this makes sense to you)

In calendar.css, add:
 #Calendar .today {
border:2px solid #000;
}


In calendar.php, there are 3 changes...
1-Change:
 (intval($_REQUEST["year"])>0) ? $cYear = intval($_REQUEST["year"]) : $cYear = date("Y"); 


To:
 (intval($_REQUEST["year"])>0) ? $cYear = intval($_REQUEST["year"]) : $cYear = date("Y");

// to highlight current day
$tDay = date("d");
$tMonth = date("m");
$tYear = date("Y");


2-Change:
 if ($current_day<10) $current_day = '0'.$current_day; 


To:
 if ($current_day<10) $current_day = '0'.$current_day;
if ($tDay == $current_day && $tMonth == $cMonth && $tYear == $cYear) { $tCurrent = "today";} else {$tCurrent = "";}


3-Change:
 if (isset($events[$cYear."-".$cMonth."-".$current_day]) && $events[$cYear."-".$cMonth."-".$current_day]<>'') {
$css='withevent';
$click = "onclick=\"LoadEvents('".$cYear."-".$cMonth."-".$current_day."')\"";
} else {
$css='noevent';
$click = '';
}


To:
 if (isset($events[$cYear."-".$cMonth."-".$current_day]) && $events[$cYear."-".$cMonth."-".$current_day]<>'') {
$css='withevent '.$tCurrent;
$click = "onclick=\"LoadEvents('".$cYear."-".$cMonth."-".$current_day."')\"";
} else {
$css='noevent '.$tCurrent;
$click = '';
}
Sparky September 16, 2014 at 11:21 pm

+2

Oh, I wish there was a preview, or edit post :( Anyways, the example CSS I gave will put a border around the 'current day', so it will be noticable, and still have a background highlight if there is an event on the same day. You can change the CSS however you want :)
Abhay September 15, 2014 at 9:41 am | Reply

0

Not working with wamp server 2.5
i tried to import database file but not able to thn i created the database..
but not able to execute in netbeans 8.0
please kindly provide me the steps how to install n how to work upon it
m a beginner
John September 1, 2014 at 4:26 am | Reply

+1

Any ideas on how to make this code work in WordPress and show 6 months on screen?
Sparky July 30, 2014 at 11:49 pm | Reply

+6

Just as an option... when you change months, the event descriptions stay there... If you want them to be removed when you change months, in calendar.js... This will have it empty the 'events' div when you change months.

Change:
function LoadMonth(month, year) {
ajaxpage("calendar.php?month="+month+"&year="+year, "Calendar");
}


To:
function LoadMonth(month, year) {
ajaxpage("calendar.php?month="+month+"&year="+year, "Calendar");
document.getElementById('Events').innerHTML="";
}
Sparky July 30, 2014 at 10:28 pm | Reply

+5

There are two things that generate massive errors, if you look at your server logs, or turn on error reporting...

In calendar.php, near the top, add your default time zone...
date_default_timezone_set('America/Chicago');

Yours will most likely be different, so dont use 'America/Chicago'. Google the term 'date_default_timezone_set' and find out what yours is!

Also, for other errors,
Change:
if ($events[$cYear."-".$cMonth."-".$current_day]<>'') {

To:
if (isset($events[$cYear."-".$cMonth."-".$current_day]) && $events[$cYear."-".$cMonth."-".$current_day]<>'') {


Both work to get rid of PHP errors. I am using both. Thanks for the 'free' software that has been tested so well... :( (free does not mean offer it even though it does not work)
matthew July 25, 2014 at 3:02 am | Reply

0

there is a bug, if we add or insert a date from 1-9 in a day , it is not highlighted.. help pls!!
Sparky July 30, 2014 at 9:23 pm

+1

The script needs 2 digits in dates to work right. The simple solution is to have the program (if your adding them through a .php script) add a leading "0" to single digit dates.
anitha July 16, 2014 at 2:14 pm | Reply

0

Please see http://www.phpjabbers.com/free-event-calendar-script/ when you click on next month or previous month the event date of the current month disabled..
Sparky July 30, 2014 at 10:15 pm

+2

That problem was corrected in comments from another member... I used it and it works!

in calendar.php, find"

(intval($_REQUEST["year"])>0) ? $cYear = intval($_REQUEST["year"]) : $cYear = date("Y");


and just under it, add this new line:

$cMonth = sprintf("%02d", $cMonth);
Dhivya July 7, 2014 at 11:19 am | Reply

0

good
maysam June 25, 2014 at 8:19 am | Reply

0

hi all

i want to ask can anyone help me to change in this script making it view line "No events to day" if there is no event added in database

thankx in advanced


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 ~