Flag This Hub

Simple Event calendar (PHP, MySQL)

By


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 ARE THE FILES:

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!

References

Build Your Own Database Driven Website Using PHP and MySQL
Amazon Price: $12.58
List Price: $39.95
PHP Cookbook: Solutions and Examples for PHP Programmers
Amazon Price: $23.34
List Price: $44.99

Comments

artfuldodger 2 years 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' 2 years 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 2 years 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 2 years 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 2 years 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 2 years ago

www.ankhcreations.com/cal.php

Andre 2 years 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 2 years 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 2 years ago

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

Thanks.

Davy.

Alpho011 2 years 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 2 years ago

Where is the code for calForm.php ?

nate 2 years 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 2 years ago

What is calStamp's purpose?

Alpho011 2 years 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 2 years 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 2 years ago

What format should the date be submitted to the database?

i.e. 06/19/2009

or 6-19-2009

Alpho011 2 years 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 2 years ago

Okay, here is my completed and manipulated calendar.

http://www.echelondon.com

Alpho011 2 years 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 2 years ago

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

williamblake 2 years ago

Wht is this.....

nate 2 years 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 2 years 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 2 years 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 2 years 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 2 years 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 2 years 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 2 years 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 2 years 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 2 years 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 2 years ago

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

qbit 2 years ago

sweet. thanks!

Graham 2 years 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 2 years ago

Nice tuts. I like it.

Alpho011 2 years 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 2 years ago

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

Omar 2 years 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 2 years ago

Ok nevermind the form just the warnings

Warning: mysql_fetch_array(): in line 180

and

Warning:mysql_num_rows () in line 244

omar 2 years ago

also there is no feb and march shows up twice

terry 2 years 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 2 years ago

u sexy but its cool u got a man

barryrutherford 2 years ago

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

nice hub

nate 2 years ago

Hi Alpho,

Did you ever create another tutorial for an archive?

louie 2 years ago

where can I find the code for calForm.php

labor law 2 years 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 2 years 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 2 years 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 2 years 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 2 years ago

Some good stuff here - thanks!

neeraa 2 years 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 2 years 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 2 years 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 2 years ago

Thanks! Love free stuff like this!

waqas yousaf 2 years 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 2 years 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 2 years ago

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

Vinayagam 2 years 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 2 years ago

hey great work some place to download this calendar

TJ 2 years 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 2 years 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 2 years 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 2 years 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 2 years 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 2 years 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 2 years 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 2 years 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 2 years 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 2 years 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 2 years 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 2 years 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 2 years 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 2 years 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 2 years 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.

sokkhim 2 years ago

Hello, I copy past code for create table and make connection in my php file. and then i copy your last final code to my dreamwaver but it not work. it can move next or pre... do you have source code for this example with database. please share! my email: camboreadcenter@gmail.com thank.

Pixielee 2 years ago

having trouble with the code, can get calender to appear and move between months but cant access any date or enter events, any help please?? source code for working with database would be great please share! email . spike734@hotmail.com thank you so much for any help!

hello dave 2 years ago

cool stuff love it

Baldwin 2 years ago

Hello.

I was wondering if anybody got this to work?

I put up the script, but I did not get any dates in my calendar, I was not able to add any event, I was not able to scroll through the months.

pravin 2 years ago

go to http://www.mahaphpcode.com

Bat 2 years ago

Hi all, How to show week number? Help Me

asha 2 years ago

February is missing and March is shown twice.

Please give me the correct code.

nicechap 2 years ago

I have tried several ways but I can't seem to make my calendar work. Will I have to save the whole script as a file? and what should I name the file? What do I have to do with the database apart from connecting to it in the script?

Anytime I tried clicking on any of the page so that I can view the calform, I get this error from the browser:

"The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster."

Alpho011, I know you have tried coming up with this script but I need to benefit from it too. Can you please send me a mail on how to save the file(s), what else to do concerning the database etc. Please help!

nicechap 2 years ago

Alpho011, you can mail me on taryour_akinola@yahoo.co.uk

Sorry, there was a little typo in the above, I wanted to tpye that anytime I ried clicking on any of the dates so that I can view the calform, I get this error from the browser:

"The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster."

Thanks.

Ashish 2 years ago

It is the best script for event calendors. I got an following error when i click on "new event" link as "Cannot redeclare hilightevt()(previously declared in calForm.php:175) calForm.php on line 208"

Please resolve this problem and send solution on my email

Thanks

ashishtupkar 2 years ago

Thanks for script, there is not a single bug, it is just not showing the current date, means that class "today" is remain on yesterday's date. please solve this problem.

Bill 2 years ago

I think this looks like a great application. and when I set it up all I get in the calendar is ">" it shows where the dates should be. Any help will be appreciated.

Michael Wallace 2 years ago

hello and thanks, this script is very useful! i was wondering how you would change how it reads dates?

Loffen 2 years ago

Please can someone post a txt file or anything including the exact code for the calForm.php I cant get it to work. the view source copy/paste doesnt seem to work, i guess im doing it wrong..

Gazza 2 years ago

@Loffen

the calForm.php is at the end of the day a PHP file, so for the code that you get from the address in an earlier post you will need to:

echo("*put HTML here*);

each line!

or you could just make it a html file, change the path names !

waveydaveywaves 2 years ago

hey I would really like to use this. can someone take this coding THAT WORKS! and put it in a zipped folder and send it to my email david7176@hotmail.com

waveydaveywaves 2 years ago

Or put a link of each file up on pastebin.com

bo! 2 years ago

Got it! Who wants the files? =)

Alice 2 years ago

Hi! I copy and paste the code, but the date didn't show up. Instead, the date turned to '>'. And I can't add any event as well. Could anyone of you please help me? I would really appreciate it...

Karyn 2 years ago

Hi bo! I saw that u manage to do this calendar..

Would u mind sharing with me??

My email: karyn_eo@hotmail.com

Thank you in advance..^^

Matt 2 years ago

hi Bo!, would it be possible for you to send the the files? I'm having a few problems getting it working!

admin@cavtec.co.uk

Thanks.

bedros 2 years ago

yeh me to can somone put it all in a zip!

sasha 2 years ago

How to show week number? Help me!!!

Dan Smith 2 years ago

Nice free code. You may want to take a look at another hub about PHP calendars

http://hubpages.com/hub/Calendar-Event-PHP

pido 2 years ago

i always this kind of error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\g1\try.php on line 187

Please Help me i have created the tables and fields correctly.. please help badly needed :(

pido 2 years ago

can you please send me a zip? i copy the code and created a mysql table and field but i still got errors..

please send me.. Here is my e-mail address:

jpido22@gmail.com

badly needed.. :(

ill appreciate your kindness..

Luke 2 years ago

Yeah i'd love to get this in a zip also please

webby_luke@hotmail.com

Appreciate it people

michael jackson 2 years ago

Does anyone can share the complete code of "calForm.php" here ?

Tomp 2 years ago

Hej bo! If you mind, please send a copy of the zip file to me too :)

Thanks in advance..

Tomp 2 years ago

Sry, my mail is; benteboy@msn.com

Lukas 2 years ago

I also have a problem with missing February and March showing twice. Can anybody help?

Dan Smith 2 years ago

You might consider polishing up your code. For an example, see http://hubpages.com/hub/calendar-event-php

Anil Kumar Panigrahi 2 years ago

Hopefully awesome article, i am going to implement it soon, thank you for sharing . . .

deluxe_k 2 years ago

i entered the events into the mysql database, but it did not display any upcoming events on the calendar.

I assume the days/dates that carry an event should have a color that signifies that. even if color isnt present, i think the event should show on the corresponding date.

Kindly sendme help on deluxe_k@yahoo.com

deluxe_k 2 years ago

i entered the events into the mysql database, but it did not display any upcoming events on the calendar.

I assume the days/dates that carry an event should have a color that signifies that. even if color isnt present, i think the event should show on the corresponding date.

Kindly sendme help on deluxe_k@yahoo.com

Harley 2 years ago

Hi everyone, I am having problems getting the code to work. I have manipulated the codes but I only have a greater than sign (>) on the dates. Can anyone help. Here is my email harleybalo@yahoo.com Thanks

riccardo 2 years ago

in 6/7 occasions the author has forgot

riccardo 2 years ago

sorry . I was writing and ... a snag ;)

THIS IS FOR HARLEY - In 6 or 7 occasions the author has forgot a sintax "

John 2 years ago

Hi, can someone please send me a zip with all the files that are working corectly as i have been stuck on a few problems for a while now.

If you can it would be greatly appreciated at johnean7@googlemail.com

Skrew 2 years ago

Its goddamn stupid not to include a zip file with code in it altough its a cool script.

yummy 2 years ago

can someone please send me a zip with all the files that are working corectly, I kind of newbie in this stuff...

little.mumu.kl@gmail.com

Alpho011 2 years ago

@ yummy

files r here

http://diadde.com/flash/cal-php.zip

Sorry to you and all people concerned

Alpho011

YourMom 2 years ago

@Alpho011

Your zip file doesn't contain the correct files. You are missing the calForm.php and you mix shorthand in your code so anyone like myself that doesn't have it setup has to go in and manually change

yummy 2 years ago

thanks, i try to setup the php 1st...

if any problem came ,, i ask again

thanks a lot

Christian 2 years ago

Well, just like most of the people here the problem for me is the calForm.php wich is not included in the .zip file... and if you view the source-code for those who have posted it you will not get the correct functions for it retrieving the date you have just clicked... so i would really appreciate the correct and full calForm.php code.

Thanks alot for a great script otherwise!

yummy 2 years ago

the next and after month button malfunction...

then the date shown as ">" instead of number...

click the date, error show up (Access forbidden! error 403)

yummy 2 years ago

somebody help me pls..

Alpho011 2 years ago

@yummy, and Christian

The files are corrected just take the SQL at the beginning of the tut, and then put in your connections, and it should do the trick right off the bat.

I apologize for the mixup.

student01 2 years ago

How can I create a form to delete and edit an entry?

Alpho011 2 years ago

@student01 at the beginning of the tut, I put a link the other day with all the files, including the form.

student01 2 years ago

I'm sorry, am I missing something? I don't see anything at the beginning of the tutorial showing how to create a delete.php or edit.php If you look at http://www.wazzis.com/calendar/cal.php you should see what I am wanting to do. when you look at an event I want the option to update/edit and delete the event from the mysql database

Alpho011 2 years ago

@student01

http://diadde.com/flash/cal-php.zip

The form is enclosed

student01 2 years ago

Thanks, I downloaded the .zip, however my question still remains.. how do I get this to delete and modify entries already made?

Alpho011 2 years ago

ok, you need to setup a way using the id of the event and then use that id in the same form you would use to create the event.

..more code

student01 2 years ago

I realize that there is more code involved. I am asking what it is.. I have no coding experience really so something to go off of would be great!

Alpho011 2 years ago

@student01

I am posting some updates to this with another entry, but here are the updated files to edit the entrys.

http://diadde.com/flash/cal-zip2.zip

Israr 2 years ago

hay man its very usefull i used it and work done thanx alot

Alpho011 2 years ago

welcome

Wii 2 years ago

Arghh.. my dates are >,,, how can you work this.. reply pleaase ):!

Alpho011 2 years ago

@wii, what is wrong?

mmd 24 months ago

My dates are also showing as ">".

Still no solution for this problem?

Alpho011 24 months ago

@mmd:

Are you grabbing the src files from the location, then all you have to modify are the db settings?

Let us know!

mmd 24 months ago

The DB settings have already been modified.

What do you mean by grabbing the src files from location'?

Alpho011 24 months ago

These are the exact files I am using on the example:

http://diadde.com/flash/cal-php.zip

Memona 24 months ago

having problem with this code :( unable to get the desired output :(

memona 24 months ago

@mmd just change the php starting tag with

Alpho011 24 months ago

@mmd post the url so we can c it.

Denisa 23 months ago

Hi! I need also help with the calendar. I would like to use this calendar to show availability. I have 2 dates: BookStart and BookEnd(in another table, I will not use the tblCal) and all the dates between these I want to be coloured. I really can't modify the function hiLightEvt($eMonth,$eDay,$eYear) to obtain what I want. Maybe you can help me.

Thanks

Denisa

Alpho011 23 months ago

@Denisa:

Sure do you have anything done already, is so post it or a link to the files to take a look, but the whole thing is to put the logic when printing the calendar out.

Take a look at the current day, how it shows the small day icon on the exact date of "today", that will give you the base logic.

Sort of if($begin_range || $end_range){//color the day

That will loop thru and color the row range or it should.

But show what you came up with, help is here.

Denisa 23 months ago

Can you please send your mail to send you the files?

Thank you.

Alpho011 23 months ago

@Denisa

Email me from the account,pls is you don't mind.

denisaa 23 months ago

I don't find your mail or how to send you a mail:D

denisaa 23 months ago

I have the next code ....but if I have multiple bookings it colours only the last date.... Also I have to generate all the dates between start and end date for each reservation.

PS.I will optimize my code after I see it works....

else{

$id = $_GET['id'];

$query = "SELECT * FROM wp_posts WHERE ID = '$id'";

$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)) {

$sql = "SELECT * FROM wp_mf_post_meta WHERE post_id = ".$id." AND (field_name = 'Book_Start_Date' OR field_name = 'Book_End_Date') ORDER BY order_id ASC";

$results = mysql_query($sql) or die(mysql_error());

$nr = mysql_num_rows($results);

while($rows = mysql_fetch_array($results)) {

//echo $rows['id'].'';

$sqlG = "SELECT * FROM wp_postmeta WHERE post_id = ".$id." AND meta_id = ".$rows['id']." ";

$resultG = mysql_query($sqlG) or die(mysql_error());

while($rowG = mysql_fetch_array($resultG)) {

$date = $rowG['meta_value'];

$dat3 = explode('-', $date);

//$date = date("Y-n-j", mktime($dat3[0], $dat3[1], $dat3[2]));

if ($dat3[1] < 10) $dat3[1] = str_replace('0', '', $dat3[1]);

if ($dat3[2] < 10) $dat3[2] = str_replace('0', '', $dat3[2]);

$date = $dat3[0] . '-' . $dat3[1] . '-' . $dat3[2];

if ($date == $dateToCompare) {

$aClass = 'class="event"';

} else {$aClass = 'class="normal"';}

}

}

}

}

return $aClass;

}

Alpho011 23 months ago

@denisa

On the contact envelope on the profile page, in the meantime I will take a look at your code post and put together some logic for you.

Raivis 23 months ago

How can i modify the code, to start week from Monday not Sunday?

Raivis 23 months ago

Got it working.

Alpho011 23 months ago

Good deal, pls share with us!

MqTontoh 23 months ago

Good tutorial and excellent script...Thanks a bunch Alpho011. Except that I cant navigate the buttons and the calendar only shows this '>' sign. I have fidgeted with it and I think the problem could be this piece of script here;

MqTontoh 23 months ago

Alpho011 23 months ago

You are welcome.

PritzP 23 months ago

Hi on the previous version I had the date showing as '>', but on the cal-2 version using the exact same database connection details, it says it cannot connect to the database. Any idea on what maybe wrong? Thanks

Alpho011 23 months ago

well you have to double check you db connection, more than likely wrong parameters.

Denisa 23 months ago

At least, I finished my project with the availability calendar.

William 23 months ago

I am trying to make this calendar work with a database with existing timestamps date(m) for month, however the "onClick="goNextMonth' sends me to the next month with "cal.php?month=6&year=2010" instead of "cal.php?month=06&year=2010"

any ideas on how to fix this?

Marc 23 months ago

I also only have "

Alpho011 23 months ago

@William

Look at the date formatting, that is being pumped thru the javascript, it needs to match the formatting of the db output.

William 23 months ago

I thought as much, but I am either not good with javascript or I can't see what changes need to be made.

function goLastMonth(month, year){

// If the month is January, decrement the year

if(month == 1){

--year;

month = 13;

}

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

}

I tried ?month='+0(month-1)+'&year='+year; which works until month 10 which returns as 010. I'd appreciate any assistance.

Alpho011 23 months ago

@William

Are you using the date formatted (in the db) as suggested or is the date formatted in a different way.

That is what is getting you.

Marc 23 months ago

I got it working!

Alpho011 23 months ago

Awesome

jonkarna 23 months ago

This hub could definitely benefit from the code module. Lets see some syntax highlighting :D

adorababy 23 months ago

This a very detailed coding and step by step process for creating an event calendar. I appreciate your time sharing this with the hub community.

Mysha 22 months ago

i really love this tutorial and i want to use this idea for a site im working on now...love php but new to it...i getting the ">" for the dates in calendar and dont really get how to link the form.

Alpho011 can use please detail all script that we should modify to get this us....ive already create and connected database. please

Alpho011 22 months ago

@Mysha:

There is a download link at the beginning that will give you the full code.

Mysha 22 months ago

Thanks for responding

Ive downloaded the code and used it. works fine. the problem I'm having is that i get a ">" sign for my all my dates, and i don't know why. could you say what i need to do to get the actual dates in the calendar. thanks much

Sherry 22 months ago

i do have the same problem as stated by Mysha.

it showing ">" instead of date .

any can help to solve?

thx for the kindness =)

aireme 22 months ago

I also encountered a same problem, like showing ">"

, and come up with a solution..

here,

i think you should try to change the

to

all of its same codes..

and then, on the database fields, change the type of the field calDate to varchar(20) instead of int(11)

Try it.. it works on me..

Tnx to Alpha^^ Nice Tut!

Mysha 22 months ago

thanks for helping aireme

not too clear what on your instructions:

"i think you should try to change the

to

all of its same codes.."

im ok with changing the database field types..

plornt 21 months ago

for those who are having ">" as dates.just change this line to .it worked for me.nice tutorial by the way.

Phil Bottomley 21 months ago

Can anyone shed some light, I want to modify the code to start a week from Monday not Sunday?

pekki 21 months ago

I'm having a problem with the code, under each date it is giving me this sign '>' can someone help me out pls. cheers

pekki 21 months ago

Has anyone found a SOLUTION to the common problem everyone seems to be having, the one where this '>' is showing rather than actual date values as seen here: http://diadde.com/test/cal.php?month=7&day=31&year

?? If you have can you share it? thnx

faxeel 21 months ago

pekki @ u got it working.. how do i get reid of this ">" no dates showing.. Please Please help out.. this cal seems perfect but i can't get it working

drootchy 21 months ago

well i tried a solution for the ">" , at the comment "right here" line , it starts with td width=50 (add) ">" be4 the php code then remove ">" after this php code ends, and then add "echo" to "$i" just be4 the a & td tags in the same line... it worked for me :))

pekki 21 months ago

@ drootchy hey could you post your codes? I didn't really get what solution you were offering. Thanks

@ faxeel I haven't found the solution yet!

drootchy 21 months ago

@pekki a link to my cal.php get to the "right here" comment... but i wonder ur calendar link is working fine

:)

http://www.mediafire.com/?krg0mqot81pc7

drootchy 21 months ago

this works better

http://www.mediafire.com/?g8h2om49db5hbqh

Anna 21 months ago

Hii..

Thanks a lot for doing such greet stuff. it really helps me a lot.

denisa 21 months ago

Hello again! I have a problem with the calendar and I don't know how it's possible. After 3 month I see that the february month is missing, it is twice march month. Do you know where the problem is?? I really don't have any idea. Thank you

pekki 21 months ago

@ drootchy thanks for that calendar, not to be funny but I am still getting the same problem, that is either wamp says there's a problem with 'Cal-2.php' (Parse error: parse error in C:\wamp\www\JUDA\cal-2.php on line 104)

OR

it gives the same problem of showing '>' under the days. My calendar isn't working WHAT I POSTED WAS AN EXAMPLE I FOUND FROM THIS SITE.

pls pls can you help me out, I am actually depending on you.

Thanks

pekki 21 months ago

Thanks guys I got it working, however I would like to try and add events and be able to view events that are particular to the day selected. For example, if there are 3 event happening on the 3rd of September and the user clicks on the 3rd of September, all 3 events should show up.

Can someone help out????

Thanks in advance

Denisa 21 months ago

No one has the some problem like me?

After 3 month of working I see that the february month is missing, it is twice march month.

Denisa 21 months ago

Hello! It' s really strange what is happening with the calendar. Yesterday February wasn't there and now it is. Is there any explanation for this?? Where can be the bug?

Deep@hubpages 20 months ago

@pekki

Can pekki or anyone else who has resolved the problem of ">" instead of dates, shed some light on how the problem is to be resolved? I really appreciate your time & i would be highly grateful if somebody could send me a zipped folder of the source files at my email "write2dpa@gmail.com". Thanks a lot in advance!!

Deep@hubpages 20 months ago

Got it, it is working perfect now! Thanks Alpho011, for sharing it. It is an elegant, compact and very efficient calendar application!!

Blair 20 months ago

So reading through the comments it seems a lot of people (including myself) have had issues with ">" appearing instead of dates and then somehow figure it out - Deep@hubpages being a recent example. Can someone please give a definitive answer for all others that follow...

Looking at the browser source code (using the exact copy of the zip from the top of the tut) it appears as though the PHP is appearing in the code instead of being parsed before hand (note the PHP code for the database connection at the top of my code has been parsed)...

Huge Thanks in advance - seems like a great resource!

Greg 20 months ago

Blair and others having issues with the ">":

Let me first say that Alpho11 has done a wonderful job on the creation of this calendar because it has few lines and highly functional as well as customizable. Thanks.

What i found was that there was a few missing php tags in the original downloaded copy of the calendar. These should be found at lines 229, 247, 260, 261, 262 You should see that the tag has a php statement in it but mine showed just a ?= at the beginning of the statement. I change this to this statement

-Line 229-

Greg 20 months ago

Seems all my post was not included. If you are still having issues send me an email gsullaway@hotmail.com

Greg 20 months ago

Something else I found out, you should include before the variable $todaysDate the date_default_timezone_set for your timezone.

Look here for your timezone:

http://www.php.net/manual/en/timezones.america.php

babu 20 months ago

when ever click on to the highlightevent date we are getting dynamic "url" instead of that i need another website link how i can replace it. pls somebody help me on this

Albin 20 months ago

i would be grateful if somebody could send me a zipped folder of the source files at my email "albinbenny@gmail.com". Thanks a lot in advance!!

Albin 20 months ago

i would be grateful if somebody could send me a zipped folder of the source files at my email "albinbenny@gmail.com". Thanks a lot in advance!!

Deep@hubpages 20 months ago

@Albin, @Greg, I have sent you the source files on your email address!

Max 20 months ago

Denisa

The missing February bug happens when todays date is greater then number of days in february.

I solved this by $day =1;

zack 19 months ago

somebody could send me the source files at my email "mahmad88@hotmail.it". Thanks.

Winter 19 months ago

Hi, i tried the code but it's not working.. when i tried downloading the source code.. it seems that the account has been suspended.. can someone send me the source code?

Thanx.

Winter 19 months ago

My Email is im4r45c4l@hotmail.com

Web Development 17 months ago

very nice tutorial as i think alot of people would like to develop something like this for themselves, also this is good to inspire and educate clients about what php developers actually do so they can understand what actually goes into some like a simple calendar.

Rob Macintosh 16 months ago

Excellent tut, thanks.

skillet 15 months ago

ah sorry about this obvious question but desperately need help....umm i made connection to ma database using

following within the following

it seems to connect to the database but the problem is it's not able to display the calender as whole just list the current month,yea thats about it could someone help....sorry fer ultimate noabness!!!!!!!!

nitin 14 months ago

please explain me each step what to do from the begining ASAP ..i have a project to do plzzz..thnx in advance

Alpho011 14 months ago

@nitin

I can't go step by step, been real busy:

here is the sql

CREATE TABLE `eventsTbl` (

`evt_id` int(11) NOT NULL auto_increment,

And here is the php, just paste in between the body tags:

##############code######################

Hi Alpho011 14 months ago

This is bountiful bro!

I am only 3weeks old in PHP so for newbie's like me this is lyke a father figure 4sure.

I create an event and it stores it in my db perfectly.

Could you please advise me how to get the events to display on the calender page, as on mine it just says no events even though the event are in my db.

Thanks bro

look forward to hearing from you.

kdiamonds 14 months ago

This is bountiful bro!

I am only 3weeks old in PHP so for newbie's like me this is lyke a father figure 4sure.

I create an event and it stores it in my db perfectly.

Could you please advise me how to get the events to display on the calender page, as on mine it just says no events even though the event are in my db.

Thanks bro

look forward to hearing from you.

Alpho011 14 months ago

@kdiamonds:

email me I will give you the src files, I took down the domain I had.

kdi 14 months ago

Hi Alpho011,

Its kdiamonds.

Thanks for getting back to me..really appreciated.

I dropped you an email as requested.

Look forward to hearing from you.

vs 13 months ago

How to implement without refreshing the page..

yan 9 months ago

can you send me calForm.php

some how i work for 2 days and still no good

thanks for the share

send me maxwell_of_chaos@yahoo.co.id

ich 9 months ago

ihr seid einfach ein paar echte Idioten!

newbie 8 months ago

hi im new in php and mysql. ive tried copying your code and i almost had everything working except im missing the calform.php

it would be great if someone give the source code for the said script. thanks in advance

Sakunne 8 months ago

An error like this:

http://alternova.ee/kalender/SimpleEventCal/

???

Sakunne 8 months ago

Were can I get those scripts_

http://diadde.com/ doesn't work anymore :(

chacha 8 months ago

can you please send me a complete package in simple calendar of event thanks in advance i need it asap for my project... here are my email address

dhianrose_aguilar@yahoo.com

Sakunne 8 months ago

Need your help .. . please send me the files:

sakunne@seenior.ee

headtail 8 months ago

please send me the complete zip file.

Here's my email bonbon20002006@yahoo.com

Thanking you

Jay 8 months ago

HI.. i need your help please send me the complete file zip thanks

Crei 8 months ago

what are the codes for the call Form.. Please Help me, .and the complete file of the calendar . here's my email .. comptech1620@yahoo.com Thanks.. Godbless

rasvi 6 months ago

hello I need to know is this one file or how many file I have to add I'm doing these days events calendar so I want to make as soon as possible

keiseichi 4 months ago

can you please send me the full code?

really appreciate it.I've been working on this for quite some time now but couldn't manage to figure it out.

help me please.

thank you.

keiseichi 4 months ago

sorry. this is my email

keiseichi@gmail.com

thanks

keiseichi 4 months ago

sorry. this is my email

keiseichi@gmail.com

thanks

salvatore 4 months ago

Hi at all...

Can I have the entire files of the calendar??I downloaded the main file but I don't have the calForm.php...

Can anyone send me an email at salvatore.zagarella[AT]gmail.com ??

Thanks...

sayuri 3 months ago

The days of calendar don´t appear !! Is this does the full code ?? Help !!

siya 3 months ago

Can you please send me the files also:

solwanes@gmail.com

czar47 3 months ago

i'm using adobe dreamweaver. when i copied the entire code i get error in this line.help me out of this.and also what is the database name tat should be created....

document.location.href

jas 3 months ago

i need the zip file too, the link doesnt work anymore.please send here: nimsaj10@yahoo.com.sg thanks in advance! Godbless :)

Kevin James 3 months ago

Can someone send me the full zip

kdorsainvil10@gmail.com

Office Test 2 months ago

cannot add new events

loans 2 months ago

Have no enough cash to buy some real estate? Do not worry, just because this is achievable to take the personal loans to work out such problems. Thence take a car loan to buy all you require.

business loans 2 months ago

Make your own life more easy take the home loans and all you want.

Mike 2 months ago

i want to download this files

xander 2 months ago

the date doesn't show, instead a grater than sign shows

Aneeq 6 weeks ago

The following link has an excellent explanation of how to enable Arabic, Urdu and other foreign language support in PHP/MySQL.

http://addr.pk/a44d

OR

http://phphelp.co/2012/03/30/how-to-make-php-and-m

Eve 2 weeks ago

can anyone send me the complete file for this event calendar ?TQ tontoro26@gmail.com

Submit a Comment
Members and Guests

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



    Like this Hub?
    Please wait working