create your own

Simple Event calendar (PHP, MySQL)

92
rate or flag this page

By Alpho011

References

Build Your Own Database Driven Website Using PHP & MySQL Build Your Own Database Driven Website Using PHP & MySQL
Price: $20.00
List Price: $39.95
PHP Cookbook PHP Cookbook
Price: $22.00
List Price: $44.99

Create a Useful Event Calendar using PHP and MySQL

We will create a useful event calendar using PHP and MySQL and a sprinkle of javascript/ CSS for functionality and look.

Here is the live example:

http://diadde.com/test/cal.php

//data base structure

CREATE TABLE IF NOT EXISTS `calTbl` (
  `calID` int(11) NOT NULL auto_increment,
  `calName` varchar(65) NOT NULL,
  `calDesc` varchar(255) NOT NULL,
  `calDate` varchar(11) NOT NULL,
  `calStamp` datetime NOT NULL,
  PRIMARY KEY  (`calID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=0;

True to past examples given here, we will create something that relies on one page to do all the work on its own, no outside files outside of calling the form that inserts the events into the database.

First off:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

Just create the doc in whatever you work in Dreamweaver etc.

Next we create the JS functions that do alot of the work:

<script>

//This does what is says go to the last month


function goLastMonth(month, year){
// If the month is January, decrement the year
if(month == 1){
--year;
month = 13;
}
document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month-1)+'&year='+year;

}

//This does what is says go to the next month
//next function
function goNextMonth(month, year){
// If the month is December, increment the year
if(month == 12){
++year;
month = 0;
}

document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month+1)+'&year='+year;
}
//This function is used on the form to control the amount of characters the input form will allow
function remChars(txtControl, txtCount, intMaxLength)
{
if(txtControl.value.length > intMaxLength)
txtControl.value = txtControl.value.substring(0, (intMaxLength-1));
else
txtCount.value = intMaxLength - txtControl.value.length;
}
//This function checks to make sure all form values are filled in before the submit button is given to the user
function checkFilled() {
var filled = 0
var x = document.form1.calName.value;
//x = x.replace(/^\s+/,""); // strip leading spaces
if (x.length > 0) {filled ++}

var y = document.form1.calDesc.value;
//y = y.replace(/^s+/,""); // strip leading spaces
if (y.length > 0) {filled ++}

if (filled == 2) {
document.getElementById("Submit").disabled = false;
}
else {document.getElementById("Submit").disabled = true} // in case a field is filled then erased

}

</script>

Now lets get into the scripting:

// Get values from query string
$day = (isset($_GET["day"])) ? $_GET['day'] : "";
$month = (isset($_GET["month"])) ? $_GET['month'] : "";
$year = (isset($_GET["year"])) ? $_GET['year'] : "";

What I am using with the above variables is using something called a ternary operator, just a shorcut to see if something is true or false:

i.e. $day = (isset($_GET["day"])) ? $_GET['day'] : "";

(isset($_GET["day"])) this condition is asking if this is SET

The ? mark divides the functionality into two phases

$_GET['day'] this value will hold true if the above condition is met

The : mark separates the true from false value.

"" this declares the variable to be empty if it not created by the $_GET querystring.

I know sometimes it takes a bit to get used to, but remember it is a good shortcut for a longer if/else condition.

function hiLightEvt($eMonth,$eDay,$eYear){
//$tDayName = date("l");
$todaysDate = date("n/j/Y");
$dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear;
if($todaysDate == $dateToCompare){
//$aClass = '<span>' . $tDayName . '</span>';
$aClass='class="today"';
}else{
//$dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear;
//echo $todaysDate;
//return;
$sql="select count(calDate) as eCount from calTbl where calDate = '" . $eMonth . '/' . $eDay . '/' . $eYear . "'";
//echo $sql;
//return;
$result = mysql_query($sql);
while($row= mysql_fetch_array($result)){
if($row['eCount'] >=1){
$aClass = 'class="event"';
}elseif($row['eCount'] ==0){
$aClass ='class="normal"';
}
}
}
return $aClass;

The above function grabs the events from our data base and matches it to a date that actually has an event. When it does that it matches the class for that day that event will be printed to the screen and the cell will be highlighted.

This is our calendar code, html with sprinklings of PHP and JS function calls (the ones we created earlier)

<table width="350" cellpadding="0" cellspacing="0">
<tr>
<td width="50" colspan="1">
<input type="button" value=" < " onClick="goLastMonth(<?php echo $month . ", " . $year; ?>);">
</td>
<td width="250" colspan="5">
<span class="title"><?php echo $monthName . " " . $year; ?></span><br>
</td>
<td width="50" colspan="1" align="right">
<input type="button" value=" > " onClick="goNextMonth(<?php echo $month . ", " . $year; ?>);">
</td>
</tr>
<tr>
<th>S</td>
<th>M</td>
<th>T</td>
<th>W</td>
<th>T</td>
<th>F</td>
<th>S</td>
</tr>
<tr>
<?php
for($i = 1; $i < $numDays+1; $i++, $counter++){
$dateToCompare = $month . '/' . $i . '/' . $year;
$timeStamp = strtotime("$year-$month-$i");
//echo $timeStamp . '<br/>';
if($i == 1){
// Workout when the first day of the month is
$firstDay = date("w", $timeStamp);
for($j = 0; $j < $firstDay; $j++, $counter++){
echo "<td>&nbsp;</td>";
}
}
if($counter % 7 == 0){
?>
</tr><tr>
<?php
}
?>
<!--right here--><td width="50" <?=hiLightEvt($month,$i,$year);?>><a href="<?=$_SERVER['PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&v=1"><?=$i;?></a></td>
<?php
}
?>
</table>

Notice:

onClick="goNextMonth(<?php echo $month . ", " . $year; ?>);

Look at the parameters inside the JS function, they are showing the month and the year, the precise vars we need to do business with in our JS, these values are spit out after the page is called and the PHP prints them out, we cannot do anything without the PHP participating in these parameters.

The following snippet does all the insertion of the new events:

<?php
if(isset($_GET['v'])){
if(isset($_POST['Submit'])){
$sql="insert into calTbl(calName,calDesc,calDate,calStamp) values('" . $_POST['calName'] ."','" . $_POST['calDesc'] . "','" . $_POST['calDate'] . "',now())";
mysql_query($sql);
}
$sql="select calName,calDesc, DATE_FORMAT(calStamp, '%a %b %e %Y') as calStamp from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'";
//echo $sql;
//return;

$result = mysql_query($sql);
$numRows = mysql_num_rows($result);
?>

You might notice in bold I usually test the SQL before I run so I can catch errors.

Here is the last of the page:

$sql="select calName,calDesc, DATE_FORMAT(calStamp, '%a %b %e %Y') as calStamp from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'";
//echo $sql;
//return;
$result = mysql_query($sql);
$numRows = mysql_num_rows($result);
?>
<a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' . $_GET['day'] . '&year=' . $_GET['year'];?>&v=1&f=true">New Event</a><br/>
<?php
if(isset($_GET['f'])){
include 'calForm.php';
}
if($numRows == 0 ){
echo '<h3>No Events</h3>';
}else{
//echo '<ul>';
echo '<h3>Events Listed</h3>';
while($row = mysql_fetch_array($result)){
?>
<div class="output">
<h5><?=$row['calName'];?></h5>
<?=$row['calDesc'];?><br/>
Listed On: <?=$row['calStamp'];?>
</div>
<?php
}
}
}
?>

The above does quite a bit for such a little snippet, it selects all the records based on date, creates a link to call the form to enter the event, gives a little feedback on it if nothing is there, and also prints to the screen the events that correspond to the date call.

Whew!

Here is the code in its entirety:

<?php
//db conn hardcode or include whichever you like
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script>
function goLastMonth(month, year){
// If the month is January, decrement the year
if(month == 1){
--year;
month = 13;
}
document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month-1)+'&year='+year;
}
//next function
function goNextMonth(month, year){
// If the month is December, increment the year
if(month == 12){
++year;
month = 0;
}
document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month+1)+'&year='+year;
}

function remChars(txtControl, txtCount, intMaxLength)
{
if(txtControl.value.length > intMaxLength)
txtControl.value = txtControl.value.substring(0, (intMaxLength-1));
else
txtCount.value = intMaxLength - txtControl.value.length;
}

function checkFilled() {
var filled = 0
var x = document.form1.calName.value;
//x = x.replace(/^\s+/,""); // strip leading spaces
if (x.length > 0) {filled ++}

var y = document.form1.calDesc.value;
//y = y.replace(/^s+/,""); // strip leading spaces
if (y.length > 0) {filled ++}

if (filled == 2) {
document.getElementById("Submit").disabled = false;
}
else {document.getElementById("Submit").disabled = true} // in case a field is filled then erased

}

</script>
<style>
body{
font-family:Georgia, "Times New Roman", Times, serif;
font-size:12px;
}
.today{
/*background-color:#00CCCC;*/
font-weight:bold;
background-image:url(calBg.jpg);
background-repeat:no-repeat;
background-position:center;
position:relative;
}
.today span{
position:absolute;
left:0;
top:0;
}

.today a{
color:#000000;
padding-top:10px;
}
.selected {
color: #FFFFFF;
background-color: #C00000;
}
.event {
background-color: #C6D1DC;
border:1px solid #ffffff;
}
.normal {

}
table{
border:1px solid #cccccc;
padding:3px;
}
th{
width:36px;
background-color:#cccccc;
text-align:center;
color:#ffffff;
border-left:1px solid #ffffff;
}
td{
text-align:center;
padding:10px;
margin:0;
}
table.tableClass{
width:350px;
border:none;
border-collapse: collapse;
font-size:85%;
border:1px dotted #cccccc;
}
table.tableClass input,textarea{
font-size:90%;
}
#form1{
margin:5px 0 0 0;
}
#greyBox{
height:10px;
width:10px;
background-color:#C6D1DC;
border:1px solid #666666;
margin:5px;
}
#legend{
margin:5 0 10px 50px;
width:200px;
}
#hr{border-bottom:1px solid #cccccc;width:300px;}
.output{width:300px;border-bottom:1px dotted #ccc;margin-bottom:5px;padding:6px;}
h5{margin:0;}
</style>
</head>

<body>
<div id="legend">
<img src="sq.jpg" /> Scheduled Events<br/><img src="calBg.jpg" height="10"/> Todays Date</div>
<?php
//$todaysDate = date("n/j/Y");
//echo $todaysDate;
// Get values from query string
$day = (isset($_GET["day"])) ? $_GET['day'] : "";
$month = (isset($_GET["month"])) ? $_GET['month'] : "";
$year = (isset($_GET["year"])) ? $_GET['year'] : "";
//comparaters for today's date
//$todaysDate = date("n/j/Y");
//$sel = (isset($_GET["sel"])) ? $_GET['sel'] : "";
//$what = (isset($_GET["what"])) ? $_GET['what'] : "";

//$day = (!isset($day)) ? $day = date("j") : $day = "";
if(empty($day)){ $day = date("j"); }

if(empty($month)){ $month = date("n"); }

if(empty($year)){ $year = date("Y"); }
//set up vars for calendar etc
$currentTimeStamp = strtotime("$year-$month-$day");
$monthName = date("F", $currentTimeStamp);
$numDays = date("t", $currentTimeStamp);
$counter = 0;
//$numEventsThisMonth = 0;
//$hasEvent = false;
//$todaysEvents = "";
//run a selec statement to hi-light the days
function hiLightEvt($eMonth,$eDay,$eYear){
//$tDayName = date("l");
$todaysDate = date("n/j/Y");
$dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear;
if($todaysDate == $dateToCompare){
//$aClass = '<span>' . $tDayName . '</span>';
$aClass='class="today"';
}else{
//$dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear;
//echo $todaysDate;
//return;
$sql="select count(calDate) as eCount from calTbl where calDate = '" . $eMonth . '/' . $eDay . '/' . $eYear . "'";
//echo $sql;
//return;
$result = mysql_query($sql);
while($row= mysql_fetch_array($result)){
if($row['eCount'] >=1){
$aClass = 'class="event"';
}elseif($row['eCount'] ==0){
$aClass ='class="normal"';
}
}
}
return $aClass;
}
?>
<table width="350" cellpadding="0" cellspacing="0">
<tr>
<td width="50" colspan="1">
<input type="button" value=" < " onClick="goLastMonth(<?php echo $month . ", " . $year; ?>);">
</td>
<td width="250" colspan="5">
<span class="title"><?php echo $monthName . " " . $year; ?></span><br>
</td>
<td width="50" colspan="1" align="right">
<input type="button" value=" > " onClick="goNextMonth(<?php echo $month . ", " . $year; ?>);">
</td>
</tr>
<tr>
<th>S</td>
<th>M</td>
<th>T</td>
<th>W</td>
<th>T</td>
<th>F</td>
<th>S</td>
</tr>
<tr>
<?php
for($i = 1; $i < $numDays+1; $i++, $counter++){
$dateToCompare = $month . '/' . $i . '/' . $year;
$timeStamp = strtotime("$year-$month-$i");
//echo $timeStamp . '<br/>';
if($i == 1){
// Workout when the first day of the month is
$firstDay = date("w", $timeStamp);
for($j = 0; $j < $firstDay; $j++, $counter++){
echo "<td>&nbsp;</td>";
}
}
if($counter % 7 == 0){
?>
</tr><tr>
<?php
}
?>
<!--right here--><td width="50" <?=hiLightEvt($month,$i,$year);?>><a href="<?=$_SERVER['PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&v=1"><?=$i;?></a></td>
<?php
}
?>
</table>
<?php
if(isset($_GET['v'])){
if(isset($_POST['Submit'])){
$sql="insert into calTbl(calName,calDesc,calDate,calStamp) values('" . $_POST['calName'] ."','" . $_POST['calDesc'] . "','" . $_POST['calDate'] . "',now())";
mysql_query($sql);
}
$sql="select calName,calDesc, DATE_FORMAT(calStamp, '%a %b %e %Y') as calStamp from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'";
//echo $sql;
//return;
$result = mysql_query($sql);
$numRows = mysql_num_rows($result);
?>
<a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' . $_GET['day'] . '&year=' . $_GET['year'];?>&v=1&f=true">New Event</a><br/>
<?php
if(isset($_GET['f'])){
include 'calForm.php';
}
if($numRows == 0 ){
echo '<h3>No Events</h3>';
}else{
//echo '<ul>';
echo '<h3>Events Listed</h3>';
while($row = mysql_fetch_array($result)){
?>
<div class="output">
<h5><?=$row['calName'];?></h5>
<?=$row['calDesc'];?><br/>
Listed On: <?=$row['calStamp'];?>
</div>
<?php
}
}
}
?>
</body>
</body>
</html>

That is it,this is not by all means the end of this conversation, there are more elegant ways to do this, I put this together quickly and welcome any feedback.

Come back soon!

Print   —   Rate it:  up  down  flag this hub

Comments

RSS for comments on this Hub

artfuldodger profile image

artfuldodger  says:
5 months ago

cool, thanks. im just starting to get into this kind of thing so this may be a stupid question but for the javascript you use jquery right?

Andre'  says:
5 months ago

Hello I'm just learning and not sure what the issue is. I have the doc's set up and I have the html page loaded but the dates are not showing. I connected to mysql database fine. Can you help? Thanks!

Alpho011 profile image

Alpho011  says:
5 months ago

artfuldodger no Jquery, just plain vanilla Javascript, I am sure you can re-fine it a bit, but will get the job done.

Alpho011 profile image

Alpho011  says:
5 months ago

Andre: everything works off the $_GET (querystring) so make sure you are copying the entire file that I have posted, once working then try to modify.

If you have an JS error let me know what it is, the code is the exact one on the online demo.

Andre' Bond  says:
5 months ago

this is the link to my site. I'm very new to this. I'm using dreamweaver, I set up my own server and website as you can probabaly tell. All i did was create one file in dreamweaver and copied the entire code into this. I tried with mysql connection and without and i get the same result. Thanks for your help

Andre  says:
5 months ago

www.ankhcreations.com/cal.php

Andre  says:
5 months ago

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; InfoPath.2; .NET CLR 3.0.30729; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)Timestamp: Thu, 18 Jun 2009 20:33:10 UTC

Message: Expected ';'Line: 13Char: 40Code: 0URI: http://www.ankhcreations.com/cal.php

Alpho011 profile image

Alpho011  says:
5 months ago

Andre:

It looks like your server is not reading the file as a PHP file,when I looked at the source code (view source).

I can still see the PHP is not parsed, that is the reason the dates are not showing up.

Take this line:

<!--right here--><td width="50" <?=hiLightEvt($month,$i,$year);?>><a href="<?=$_SERVER['../PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&amp;v=1"><?=$i;?></a></td>It is showing the PHP which should have been parsed by the server, check yourinstallation, after wards, take the entire script and recopy it, dont change anything just re-copy.

davlin  says:
5 months ago

Hi, could you help us to create the database table calTbl?

Thanks.

Davy.

Alpho011 profile image

Alpho011  says:
5 months ago

davlin:

CREATE TABLE IF NOT EXISTS `calTbl` ( `calID` int(11) NOT NULL auto_increment, `calName` varchar(65) NOT NULL, `calDesc` varchar(255) NOT NULL, `calDate` varchar(11) NOT NULL, `calStamp` datetime NOT NULL, PRIMARY KEY (`calID`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Drop that into a SQL analyzer and it will do the trick.

nate  says:
5 months ago

Where is the code for calForm.php ?

nate  says:
5 months ago

Found it:

Event Name Event Desc You have characters left! Event Date

And had I refreshed my browser I would have found the db info i was looking for.

cheers :)

nate  says:
5 months ago

What is calStamp's purpose?

Alpho011 profile image

Alpho011  says:
5 months ago

calStamp's purpose is to give a time stamp to the entries, which in this example holds no purpose but can be very useful in when the entry was complete.

nate  says:
5 months ago

hmmm...okay. thanks!

Also, how could you make it so only the days which contained events were clickable links.

bad example :

if event=true {

echo '<a href=""...></a>' ;

else {

echo '<date>15</..>'}

nate  says:
5 months ago

What format should the date be submitted to the database?

i.e. 06/19/2009

or 6-19-2009

Alpho011 profile image

Alpho011  says:
5 months ago

Nate: the conditional is exactly what you would use as far as the date format, it can be whatever you want, format it as you please.

good luck

nate  says:
5 months ago

Okay, here is my completed and manipulated calendar.

http://www.echelondon.com

Alpho011 profile image

Alpho011  says:
5 months ago

nate:

awesome, take a look at the javascript for the function for next month, it spit out an error page, great work.

Also, take it one step further offer more interactivity, experiment with some AJAX and more javascript, (to keep the person on the same page, no refresh), once again great work, don't stop.

expectus profile image

expectus  says:
5 months ago

nice hub I will give this a try:) its great to understand how all the code actually makes it work

williamblake profile image

williamblake  says:
5 months ago

Wht is this.....

nate  says:
4 months ago

Thanks alpho011, I'm working on that error. And i will definitely look into some javascript to keep the user on the same page. Any links for tutorials? Or what to search for?

And I probably won't touch AJAX ... i think that might be beyond me.

Im more of a designer than a coder ;)

Also, im sure you could use parts of this code, but maybe you could help making a monthly archive?

THANKS!

Alpho011 profile image

Alpho011  says:
4 months ago

sure let me know what you help on, I will be glad to help as I can, and on what to use just some straight javascript, and pull the dates the same way on the calendar as with the same query.

I want to update this with something like that but this way is short and sweet, it keeps the tutorial short and doesn't discourage readers.

nate  says:
4 months ago

The error was when I changed from buttons to a link I forgot to add javascript: in front of the function.

All fixed :)

Now to tackle the archive

Jeff  says:
4 months ago

Hi below is my connection info which doesn't seem to work, is this right? (usernames and passwords removed for safter

<?php $username = "username";$password = "password";$hostname = "localhost"; $dbh = mysql_connect($hostname, $username, $password) ?>

Jeff  says:
4 months ago

I got the connection working (duh me!) but now i get this error:

Untitled Document function goLastMonth(month, year){ // If the month is January, decrement the year if(month == 1){ --year; month = 13; } document.location.href = '/v2classroom/cal.php?month='+(month-1)+'&year='+year; } //next function function goNextMonth(month, year){ // If the month is December, increment the year if(month == 12){ ++year; month = 0; } document.location.href = '/v2classroom/cal.php?month='+(month+1)+'&year='+year; } function remChars(txtControl, txtCount, intMaxLength) { if(txtControl.value.length > intMaxLength) txtControl.value = txtControl.value.substring(0, (intMaxLength-1)); else txtCount.value = intMaxLength - txtControl.value.length; } function checkFilled() { var filled = 0 var x = document.form1.calName.value; //x = x.replace(/^\s+/,""); // strip leading spaces if (x.length > 0) {filled ++} var y = document.form1.calDesc.value; //y = y.replace(/^s+/,""); // strip leading spaces if (y.length > 0) {filled ++} if (filled == 2) { document.getElementById("Submit").disabled = false; } else {document.getElementById("Submit").disabled = true} // in case a field is filled then erased } body{ font-family:Georgia, "Times New Roman", Times, serif; font-size:12px; } .today{ /*background-color:#00CCCC;*/ font-weight:bold; background-image:url(calBg.jpg); background-repeat:no-repeat; background-position:center; position:relative; } .today span{ position:absolute; left:0; top:0; } .today a{ color:#000000; padding-top:10px; } .selected { color: #FFFFFF; background-color: #C00000; } .event { background-color: #C6D1DC; border:1px solid #ffffff; } .normal { } table{ border:1px solid #cccccc; padding:3px; } th{ width:36px; background-color:#cccccc; text-align:center; color:#ffffff; border-left:1px solid #ffffff; } td{ text-align:center; padding:10px; margin:0; } table.tableClass{ width:350px; border:none; border-collapse: collapse; font-size:85%; border:1px dotted #cccccc; } table.tableClass input,textarea{ font-size:90%; } #form1{ margin:5px 0 0 0; } #greyBox{ height:10px; width:10px; background-color:#C6D1DC; border:1px solid #666666; margin:5px; } #legend{ margin:5 0 10px 50px; width:200px; } #hr{border-bottom:1px solid #cccccc;width:300px;} .output{width:300px;border-bottom:1px dotted #ccc;margin-bottom:5px;padding:6px;} h5{margin:0;} Warning: include(calForm.php) [function.include]: failed to open stream: No such file or directory in c:\wamp\www\v2classroom\cal.php on line 251Warning: include() [function.include]: Failed opening 'calForm.php' for inclusion (include_path='.;C:\php5\pear') in c:\wamp\www\v2classroom\cal.php on line 251

Jeff  says:
4 months ago

Sorry about the above post please delete it, i am getting these errors:

Warning: include(calForm.php) [function.include]: failed to open stream: No such file or directory in c:\wamp\www\v2classroom\cal.php on line 251Warning: include() [function.include]: Failed opening 'calForm.php' for inclusion (include_path='.;C:\php5\pear') in c:\wamp\www\v2classroom\cal.php on line 251

nate  says:
4 months ago

You are trying to link to the files cal.php and calForm.php.

Make sure these files exist and in the proper directories you are linking too

Mac Mission profile image

Mac Mission  says:
4 months ago

Hi,

Your articles are most beautiful but i wanted to learn connectivity between flex and php. I am struggling to do so. Can you help me on this?

Sorin  says:
4 months ago

DO NOT EVER use this "echo $_SERVER['PHP_SELF'];" .. and I mean EVER without at least passing that throught html_entities or just use something else..

please learn some php security ethics and then teach people... and search google about how dangerous is that variable..

.. nice article but watch out for security issues.. begining totorials or not .. security is a must.. bad practice is easy to learn :)

nicomp profile image

nicomp  says:
4 months ago

I'm sure the author has 'security ethics'.

qbit  says:
4 months ago

sweet. thanks!

Graham  says:
4 months ago

i keep getting the following error where is the code for calForm.php

Warning: include(calForm.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\xampp\temp\cal.php on line 2

iqbal  says:
3 months ago

Nice tuts. I like it.

Alpho011 profile image

Alpho011  says:
3 months ago

Graham, you are getting the error because the path to the form is either wrong or the folder with the included form does not exist.

Marcelo  says:
3 months ago

where is the calForm.php?? I couldn´t find it , would you help me???

Omar  says:
3 months ago

same problem where is the script for calForm.php and I am getting the error message

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

above all the dates in the cal.

please help

Omar  says:
3 months ago

Ok nevermind the form just the warnings

Warning: mysql_fetch_array(): in line 180

and

Warning:mysql_num_rows () in line 244

omar  says:
3 months ago

also there is no feb and march shows up twice

terry  says:
3 months ago

Hello can you post the script on the form you used with calendar. Also im using php 5 on my server but having problems with the mysql_fetch_array and mysql_num_rows

Thanks

by the way great calendar

jordan23jay  says:
3 months ago

u sexy but its cool u got a man

barryrutherford profile image

barryrutherford  says:
3 months ago

That'a a very useful set of codes. I think ill just stick to the filofax & pencil...

nice hub

nate  says:
3 months ago

Hi Alpho,

Did you ever create another tutorial for an archive?

louie  says:
3 months ago

where can I find the code for calForm.php

labor law  says:
3 months ago

You gave us fantastic pieces of code, Thanks so much for sharing it! I was having problems while creating event caledars. Other solutions weren't so friendly.

I’m very glad to try this.

http://www.xn------wpehbcibg3bcah2ftaym6h.com/1195

aby  says:
3 months ago

thanx for your calendar. do you have any modified version of this calender?. i mean a better css or so..and also can you help me with inserting multiple values starting from a date to some other date

for example from 06-08-2009 to 09-08-2009.

aby  says:
3 months ago

louie,

here is the code for calForm.php

function goLastMonth(month, year){

// If the month is January, decrement the year

if(month == 1){

--year;

month = 13;

}

document.location.href = 'aby_cal.php?month='+(month-1)+'&year='+year;

}

//next function

function goNextMonth(month, year){

// If the month is December, increment the year

if(month == 12){

++year;

month = 0;

}

document.location.href = 'aby_cal.php?month='+(month+1)+'&year='+year;

}

function remChars(txtControl, txtCount, intMaxLength)

{

if(txtControl.value.length > intMaxLength)

txtControl.value = txtControl.value.substring(0, (intMaxLength-1));

else

txtCount.value = intMaxLength - txtControl.value.length;

}

function checkFilled() {

var filled = 0

var x = document.form1.calName.value;

//x = x.replace(/^\s+/,""); // strip leading spaces

if (x.length > 0) {filled ++}

var y = document.form1.calDesc.value;

//y = y.replace(/^s+/,""); // strip leading spaces

if (y.length > 0) {filled ++}

if (filled == 2) {

document.getElementById("Submit").disabled = false;

}

else {document.getElementById("Submit").disabled = true} // in case a field is filled then erased

}

Event Name

Event Desc

You have

characters left!

Event Date

aby  says:
3 months ago

louie,

here is the code for calForm.php

function goLastMonth(month, year){

// If the month is January, decrement the year

if(month == 1){

--year;

month = 13;

}

document.location.href = 'aby_cal.php?month='+(month-1)+'&year='+year;

}

//next function

function goNextMonth(month, year){

// If the month is December, increment the year

if(month == 12){

++year;

month = 0;

}

document.location.href = 'aby_cal.php?month='+(month+1)+'&year='+year;

}

function remChars(txtControl, txtCount, intMaxLength)

{

if(txtControl.value.length > intMaxLength)

txtControl.value = txtControl.value.substring(0, (intMaxLength-1));

else

txtCount.value = intMaxLength - txtControl.value.length;

}

function checkFilled() {

var filled = 0

var x = document.form1.calName.value;

//x = x.replace(/^\s+/,""); // strip leading spaces

if (x.length > 0) {filled ++}

var y = document.form1.calDesc.value;

//y = y.replace(/^s+/,""); // strip leading spaces

if (y.length > 0) {filled ++}

if (filled == 2) {

document.getElementById("Submit").disabled = false;

}

else {document.getElementById("Submit").disabled = true} // in case a field is filled then erased

}

Event Name

Event Desc

You have

characters left!

Event Date

rickydeez profile image

rickydeez  says:
3 months ago

Some good stuff here - thanks!

neeraa  says:
3 months ago

I am just at the beginning and all this stuff is very new to me. I know very little about PHP and nothing about MySql. Therefore difficult to understand how to handle this script in a web page. I just upload this whole script as it is, you can see it on below link

http://neeraa.co.cc/calenr.php

Please some one tell me what should I do in order to correct this errors to get the calendar.

Thanks for your time

Jim  says:
3 months ago

Hey, thanks for sharing this. It’s been a long road trying to find an efficient calendar script. Unfortunately I keep running into small errors here and there with this one. I’m new to both PHP and MySql, so I’m sure I’m making some dumb mistakes.

It would be great if you could provide a readymade package with the completed PHP files and possibly a sql file I could import. That would at least remove any possibility of me corrupting your code and building an improper DB. I prefer to reverse engineer anyway when I’m dealing with a new language.

I realize that’s asking a lot. If it’s too much, then at least providing a complete version of calForm.php would be a great help in itself.

Thanks

zampano  says:
3 months ago

Beautiful work.

But since the main event behind changing (clicking) on a date figure is to refresh a text field, why reloading the whole page ?

Please dont think I'm too pretentious but I think you could just refresh the field contents, leaving the calendar grid untouched, thus avoiding that disagreable visual effect of the whole page reloading.

Greetings and congratulations.

Zampano

1AutomationWiz profile image

1AutomationWiz  says:
3 months ago

Thanks! Love free stuff like this!

waqas yousaf  says:
3 months ago

i am having such an output just after the today's date

Scheduled Events

Todays Date

8/14/20091249084800

1249171200

1249257600

1249344000

1249430400

1249516800

1249603200

1249689600

1249776000

1249862400

1249948800

1250035200

1250121600

1250208000

1250294400

1250380800

1250467200

1250553600

1250640000

1250726400

1250812800

1250899200

1250985600

1251072000

1251158400

1251244800

1251331200

1251417600

1251504000

1251590400

1251676800

and instead of showing dates, its just showing '>' in calendar. Please Help me out

waqas yousaf  says:
3 months ago

would u please send me the complete source code of the calender like u have put on demonstration on this website?

My email ID is wiqi@live.com

Nate  says:
3 months ago

Did you ever end up creating a tutorial for an archive?

Vinayagam  says:
3 months ago

Very appreciable calendar...this is what i am searching long time...where is the calForm.php?

I too getting the same error..

Warning: include(calForm.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\Try\Event Calendar\test\cal.php on line 251

Warning: include() [function.include]: Failed opening 'calForm.php' for inclusion (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\Try\Event Calendar\test\cal.php on line 251

plz...Some one help me...

Thanks in advance..

javier  says:
2 months ago

hey great work some place to download this calendar

TJ  says:
2 months ago

What can I do to make the calendar but not make a link if there is no database entry for that day?

Chris Seckler  says:
2 months ago

Great looking script! I am trying to recreate it, but I don't know what your database structure is. Can i get a copy of your work files or can you show me the database structure? Also, what is the calForm.php file?

ivan  says:
2 months ago

what are you calling the database that the table calTbl resides in? i keep on getting an errors:

Warning: mysql_query() [function.mysql-query]: Access denied for user 'olympiao'@'localhost' (using password: NO) in /home3/olympiao/public_html/calender.php on line 178

and

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home3/olympiao/public_html/calender.php on line 179

Raivis  says:
2 months ago

where is the calForm.php? While reading the comments, i understood that it has the some code as tag at the top. How can i get it working as one file as it was mentioned at the begining of tutorial?

Alpho011 profile image

Alpho011  says:
2 months ago

CREATE TABLE IF NOT EXISTS `calTbl` (

`calID` int(11) NOT NULL auto_increment,

`calName` varchar(65) NOT NULL,

`calDesc` varchar(255) NOT NULL,

`calDate` varchar(11) NOT NULL,

`calStamp` datetime NOT NULL,

PRIMARY KEY (`calID`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;

wizard0522  says:
2 months ago

Hello,

I am new here and I was wondering if someone can please help me out with the calForm.php. I got the code from up above from aby and I am getting a an error...

Parse error: syntax error, unexpected ',', expecting '&' or T_VARIABLE in /home/xxxxxxx/public_html/final/calForm.php on line 2

this is line 2

Danny Pryor  says:
5 weeks ago

Actually, I believe this is the code for the calForm.php file. All in all, though - this is a FANTASTIC script. Alpho11, great stuff!

Script for calForm.php:

Event Name

Event Desc

You have

characters left!

Event Date

Danny Pryor  says:
5 weeks ago

Wow ... I just realized that post doesn't show the code ... I guess I should read the instructions! LOL! Sorry about that ... so go to the following address, and view code, copy and paste it. You'll have it then. http://rodanmedia.net/Alpho11/calForm.php

Rodan profile image

Rodan  says:
5 weeks ago

You can also grab http://rodanmedia.net/Alpho11/calForm2.php, which is customized a bit for a site we're developing. It removes the automatic date insertion on the event date, allowing a user to type their own. The table layout is modified.

Mark  says:
4 weeks ago

Great utility! Exactly what we were looking for:

We seem to be having some difficulty with the DB connection

though. It seemingly ignores our usual stuff and wants to hit the DB as apache@localhost! Any thoughts on how we should be opening/closing?

Seth  says:
3 weeks ago

Hi Alpho011,

I just have a quick question about this great utility.

Has anyone come up with a way to create recurring events?

Thanks!

-sk

Nans  says:
2 weeks ago

An help would be appreciated..

I get this ERROR:

Fatal error: Cannot redeclare hilightevt() (previously declared in /home/docs/ucoll/docs/docs/estudio/cal.php:165) in /home/docs/ucoll/docs/docs/estudio/calForm.php on line 163

Thanks.

jwhiteaker9  says:
8 days ago

I need help I have the database working and the page made. When I load it. It doesn't have any numbers or can I change months. I dont think JS is working on my test server. Is there a way to find out? Using latest copy of Xampp with Tomcat addon.

ibasco  says:
5 days ago

@Danny Pryor you can't just copy the php file. there is an important functions inside there that muse be seen literally. the creator must post his code himself for it to be working properly

Oscar  says:
17 hours ago

Im having a problem where the calendar doesnt read the events from the DB. Anyone else has this problem?

Also the date function in the New Event doesnt seem to work, all i get is date: //

The Event gets added in the correct table in the database but doesnt load afterwards.

Submit a Comment

Members and Guests

Sign in or sign up and post using a hubpages account.


optional


  • No HTML is allowed in comments, but URLs will be hyperlinked
  • Comments are not for promoting your hubs or other sites

working