• (3 Pages)
  • +
  • 1
  • 2
  • 3

Event Tracking Calendar Rate Topic: ***** 1 Votes

#31 dtown  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 19-June 12

Posted 22 June 2012 - 09:30 AM

Quote

// Formatting for SQL datetime (if this is edited, it will NOT work.)
$event_date = $y."-".$m."-".$d." ".$_POST["event_time_hh"].":".$_POST["event_time_mm"].":00";


For folks who are not copying and pasting, what can be difficult to see here is the "space" between $d." and ".$_POST. Took me a solid two hours debugging this problem, so I wanted to share my experience here in hopes to helping out someone else.

Good tutorial, thanks.
Was This Post Helpful? 0
  • +
  • -

#32 Sgleaton  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-June 12

Posted 22 June 2012 - 09:54 AM

View Postdtown, on 22 June 2012 - 09:30 AM, said:

Quote

// Formatting for SQL datetime (if this is edited, it will NOT work.)
$event_date = $y."-".$m."-".$d." ".$_POST["event_time_hh"].":".$_POST["event_time_mm"].":00";


For folks who are not copying and pasting, what can be difficult to see here is the "space" between $d." and ".$_POST. Took me a solid two hours debugging this problem, so I wanted to share my experience here in hopes to helping out someone else.

Good tutorial, thanks.



Am I understanding this correctly? There are only two files to this, calendar.php and events.php; then setup your MySQL. THAT IS ALL??

-Scott Gleaton
Was This Post Helpful? 0
  • +
  • -

#33 dtown  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 19-June 12

Posted 22 June 2012 - 10:31 AM

View PostSgleaton, on 22 June 2012 - 09:54 AM, said:

Am I understanding this correctly? There are only two files to this, calendar.php and events.php; then setup your MySQL. THAT IS ALL??


Correct. If you're stuck or have any questions let me know, I've been using this tutorial the past few days and I'm happy to help if able.
Was This Post Helpful? 0
  • +
  • -

#34 Kritter5x  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 15-July 12

Posted 15 July 2012 - 10:09 PM

This tutorial is fantastic and easy enough to follow. I managed to edit it to work with my own event editor, which is a huge bonus for me.

I would like to ask how to do a few things though, if that's possible from anyone?

Firstly, would it be possible to have a "next" and "previous" month buttons, instead of choosing the month? Ultimately it's not that big of a deal, but it would be a nice little feature to have.

My other question would be, rather than putting the event name on the day when there's an event, would it be possible to simply color the cell? For what i'm doing, it's likely there'd be a few events posted for a single day and the calendar would likely be in a small area so multiple event titles would stretch it too much.

Thanks in advance!
Was This Post Helpful? 0
  • +
  • -

#35 Kritter5x  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 15-July 12

Posted 16 July 2012 - 01:08 AM

Oh and I hope i'm not asking too much, but I was wondering if it would be possible to add some kind of event filtering system to this?

I have categories for events, and i'd like to be able to filter what's displayed on the calendar based on the category of events. I assume a drop-down box would do the trick, but I couldn't work out how to do it.
Was This Post Helpful? 0
  • +
  • -

#36 Kritter5x  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 15-July 12

Posted 17 July 2012 - 08:41 PM

Apologies for multi-posting, I can't seem to find an option to edit posts though.

Just thought i'd leave a small update for this that I managed to wrangle in regarding colouring cells that have an event in them. Here's the code I used for that:

for ($count=0; $count < (6*7); $count++) {
	$dayArray = getdate($start);
	if (($count % 7) == 0) {
		if ($dayArray["mon"] != $month) {
			break;
		} else {
			echo "</tr><tr>\n";
		}
	}
	if ($count < $firstDayArray["wday"] || $dayArray["mon"] != $month) {
		echo "<td style=\"background-color: #EEEEEE\">&nbsp;</td>\n";
	} else {
		$chkEvent_sql = "SELECT event_name FROM events WHERE event_category='Category 1' AND month(event_date) = '".$month."' AND dayofmonth(event_date) = '".$dayArray["mday"]."' AND year(event_date) = '".$year."' ORDER BY event_date";
		$chkEvent_res = mysql_query($chkEvent_sql, $mysql) or die(mysql_error($mysql));

		if (mysql_num_rows($chkEvent_res) > 0) {
			$event_name = "";
			$event_format1 = "";
			$event_format2 = "";
			$event_format3 = "#FFFFFF";
			
			if ($ev = mysql_fetch_array($chkEvent_res)) {
				$event_name .= stripslashes($ev["event_name"])."<br/>";
				$event_format1 = "<b>";
				$event_format2 = "</b>";
				$event_format3 = "#CCCCCC";
			}
			mysql_free_result($chkEvent_res);
		} else {
			$event_name = "</br>";
			$event_format1 = "";
			$event_format2 = "";
			$event_format3 = "#FFFFFF";
		}

		echo "<td style=\"background-color: $event_format3\"\"valign=\"top\">".$event_format1."<a href=upcomingevents.php?m=".$month."&d=".$dayArray["mday"]."&y=$year\">".$dayArray["mday"]."</a>".$event_format2."<br/>".$event_name."</td>\n";
		unset($event_name);

		$start += ADAY;
	}
}



This formats any cell that has an event in it by using $event_formatX parts to make the date number bold and colours the cell based on the hex value put in there. There may be a better way to do it, but that's what I came up with.

Now all I need to do is find a way to filter by event category and i'm set.
Was This Post Helpful? 0
  • +
  • -

#37 zegmagnes  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 28-November 12

Posted 03 December 2012 - 01:41 AM

im also want to ask how to EDIT and DELETE every event that we add from the script that provide in the first page.. it cam make our system more systematic.

thanks for those who help me.
Was This Post Helpful? 0
  • +
  • -

#38 sjoerd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 15-February 13

Posted 15 February 2013 - 06:59 AM

I created some extra code in order to highlight the present day (just a simple if-statement, if it's todays day en todays month give the cell the color lightgreen:

<?php
// At line 2 of our calendar.php script, add the MySQL connection information:
$mysql = mysql_connect("localhost", "root", "");
mysql_select_db("calendar", $mysql) or die(mysql_error());

// Now we need to define "A DAY", which will be used later in the script:
define("ADAY", (60*60*24));


if ((!isset($_POST['month'])) || (!isset($_POST['year']))) {
	$nowArray = getdate();
	$month = $nowArray['mon'];
	$year = $nowArray['year'];
} else {
	$month = $_POST['month'];
	$year = $_POST['year'];
}
$start = mktime(12,0,0,$month,1,$year);
$firstDayArray = getdate($start);
?>
<html>
<head>
<title><?php echo "Calendar: ".$firstDayArray['month']."" . $firstDayArray['year']; ?></title>
<script LANGUAGE="Javascript">
<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=780,height=550, left = 0,top = 150');");
}
// End -->
</script>

</head>
<body>


<h3 align="center">Selecteer een maand/Jaar</h3>
<form method="post" action="<?php echo $_SERVER['../calender/PHP_SELF']; ?>">
  <div align="center">
    <select name="month">
      <?php
$months = Array("Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December");

for ($x=1; $x<=count($months); $x++){
	echo "<option value=\"$x\"";
	if ($x == $month){
		echo " selected";
	}
	echo ">".$months[$x-1]."</option>";
}
?>
    </select>
    <select name="year">
      <?php
for ($x=2000; $x<=2015; $x++){
	echo "<option";
	if ($x == $year){
		echo " selected";
	}
	echo ">$x</option>";
}
?>
    </select>
  <input type="submit" name="submit" value="Zoeken!">
  </div>
</form>
<br />
<?php
$days = Array("Zondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag");
echo "<table border=\"2\" cellpadding=\"5\"><tr>\n";
echo "<col width=100>
 <col width=100>
 <col width=100>
 <col width=100>
 <col width=100>
 <col width=100>
 <col width=100>";
foreach ($days as $day) {
	echo "<td style=\"background-color: #CCCCCC; text-align: center;\">
	      <strong>$day</strong></td>\n";
}

for ($count=0; $count < (6*7); $count++) {
	$dayArray = getdate($start);
	if (($count % 7) == 0) {
		if ($dayArray["mon"] != $month) {
			break;
		} else {
			echo "</tr><tr>\n";
		}
	}
	if ($count < $firstDayArray["wday"] || $dayArray["mon"] != $month) {
		echo "<td> </td>\n";
	} else {
		$chkEvent_sql = "SELECT event_title FROM calendar_events WHERE month(event_start) = '".$month."' AND dayofmonth(event_start) = '".$dayArray["mday"]."' AND year(event_start) = '".$year."' ORDER BY event_start";
		$chkEvent_res = mysql_query($chkEvent_sql, $mysql) or die(mysql_error($mysql));

		if (mysql_num_rows($chkEvent_res) > 0) {
			$event_title = "<br/>";
			while ($ev = mysql_fetch_array($chkEvent_res)) {
				$event_title .= stripslashes($ev["event_title"])."<br/>";
			}
			mysql_free_result($chkEvent_res);
		} else {
			$event_title = "";
		}
if ($dayArray["mday"]==date(d)&&$month==date(m)) {
	    echo "<td style=\"background-color: lightgreen; text-align: center;\">
	     <A HREF=\"javascript:popUp('event.php?m=".$month."&d=".$dayArray["mday"]."&y=$year')\">".$dayArray["mday"]."</A><br>".$event_title."</td>\n"; } 
		  else {
		echo "<td valign=\"center\"><A HREF=\"javascript:popUp('event.php?m=".$month."&d=".$dayArray["mday"]."&y=$year')\">".$dayArray["mday"]."</A><br>".$event_title."</td>\n"; }


		unset($event_title);

		$start += ADAY;
	}
}
echo "</tr></table>";
mysql_close($mysql);
?>
</body>
</html>




Was This Post Helpful? 0
  • +
  • -

#39 srlemax  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 13-October 13

Posted 13 October 2013 - 01:14 AM

Can you help me with this message.


Forbidden

You don't have permission to access /php_Sandbox/java script:eventWindow('event.php on this server.
Was This Post Helpful? 0
  • +
  • -

#40 Eluway  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 29-June 11

Posted 14 October 2013 - 07:47 PM

View Postsrlemax, on 13 October 2013 - 01:14 AM, said:

Can you help me with this message.


Forbidden

You don't have permission to access /php_Sandbox/java script:eventWindow('event.php on this server.



Please include your code, otherwise it's practically impossible to tell you what is wrong
Was This Post Helpful? 0
  • +
  • -

#41 Ashley83  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 24-January 14

Posted 24 January 2014 - 02:07 PM

After spending many hours looking for a free and flexible calendar, this has to be the absolute best which I have managed to find. I have been trying to adapt this calander so rather than just displaying the start date of the event displaying the event for the duration of the date, so if an event runs from 1st to 3rd September it would display the event under boxes 1st, 2nd and 3rd of September

I have found out how to echo the the array of dates below

 
// updated query
$chkEvent_sql = "SELECT event_start, event_finish FROM calendar_events";

	
	$row = mysql_fetch_assoc($chkEvent_sql);
	
	
	
	$startTime = strtotime($row[event_start]);	
	
	// I have added extra field of when the event finishes
	$endTime = strtotime($row[event_finish]);


	// Loop between timestamps, 24 hours at a time
	for ( $i = $startTime; $i <= $endTime; $i = $i + 86400) {
	$thisDate = date('Y-m-d', $i); // this echos out a list of dates from the start and end date of the event
	
	print "$thisDate <br> ";
	}
	


I think I should therefore edit (from the original posted script)

echo "<td valign=\"top\"><a href=\"java script:eventWindow('event.php?m=".$month."&d=".$dayArray["mday"]."&y=$year');\">".$dayArray["mday"]."</a><br/>".$event_title."</td>\n";

to include my array of dates, has anyone else tried this or know if I am going in the wrong direction in what I am doing. I am new to posting on this forum and hope that does not count as someone doing my homework for me.
Was This Post Helpful? 0
  • +
  • -

#42 csyfer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 03-May 14

Posted 03 May 2014 - 07:55 PM

this is something i have been working on..and your code has helped alot..but my question and my problem im currently tackling is..i want to create a Going / Not Going / Maybe attending for my members so they know who all will be at the event.. how can i do this?
Was This Post Helpful? 0
  • +
  • -

#43 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10596
  • View blog
  • Posts: 39,259
  • Joined: 27-December 08

Posted 03 May 2014 - 08:27 PM

The author of this tutorial has not been online in over a year. I think it's a fair assessment to say that asking about features not covered in this tutorial will not garner much. If you have some good faith efforts to show, you may wish to post in our general PHP forum for help.
Was This Post Helpful? 0
  • +
  • -

#44 hobbasibba  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 31-May 14

Posted 31 May 2014 - 06:49 PM

View Postscottryan, on 02 February 2011 - 11:17 AM, said:

Alright after coming back to it with some fresh eyes, I got it. It was in calendar.php
It is the following line of code in the calendar.php file. Around line #90. Right where year is, I deleted '); right after year. Hope this helps someone else.
The code below is how it should be.
Scott

echo "<td valign=\"top\"><a href=event.php?m=".$month."&d=".$dayArray["mday"]."&y=$year\">".$dayArray["mday"]."</a><br/>".$event_title."</td>\n";


Let me first say, this tutorial was the best I have found, even if it is months (years?) old. I'd tried following and coding several, including those on YouTube. Many thanks for providing it. That said, your solution to delete '); was almost completely correct however I believe only the semi-colon should be deleted. Additionally, in the supplied code, at the start of the <a href=\"java script:eventwindow... there is a space between the words java and script that shouldn't be there. It's this space that is causing the url to be misinterpreted by the javascript function defined at the top of the html, and which results in the misleading 'Forbidden' message to be thrown. Hope this helps others who may want to use your example.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3