<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:series="http://unfoldingneurons.com/"
> <channel><title>Comments on: Add Events to the PHP&#160;Calendar</title> <atom:link href="http://davidwalsh.name/php-event-calendar/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name/php-event-calendar</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Thu, 09 Feb 2012 09:13:01 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3</generator> <item><title>By: Mike</title><link>http://davidwalsh.name/php-event-calendar/comment-page-1#comment-29086</link> <dc:creator>Mike</dc:creator> <pubDate>Tue, 07 Feb 2012 16:41:18 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4403#comment-29086</guid> <description>Hi. Just stumbled on this site looking for  calendar for my community website. I&#039;d like to allow users to pick multiple dates from a calendar if they wish. Sometimes an event, like a play, may be on different unrelated dates, like a Mon, Wed, Sat, etc.I&#039;m guessing there would be a popup calendar that would allow them to click on the dates or maybe just having a checkbox if they have multiple events and sending the entry page back with the data filled in already (except date) and then they could choose another date.I&#039;m still kicking this around and really don&#039;t know how to go on this project. Any thoughts on this? I&#039;m a little beyond newbie but still learning php, MySQL and can get around a script okay. Was a COBOL programmer analyst for many years, so have an idea of process of a project.If anyone knows of a calendar that does this already, I&#039;d appreciate a link so I can take a look. Thanks. And thank you David for the great work on your blog.</description> <content:encoded><![CDATA[<p>Hi. Just stumbled on this site looking for  calendar for my community website. I&#8217;d like to allow users to pick multiple dates from a calendar if they wish. Sometimes an event, like a play, may be on different unrelated dates, like a Mon, Wed, Sat, etc.</p><p>I&#8217;m guessing there would be a popup calendar that would allow them to click on the dates or maybe just having a checkbox if they have multiple events and sending the entry page back with the data filled in already (except date) and then they could choose another date.</p><p>I&#8217;m still kicking this around and really don&#8217;t know how to go on this project. Any thoughts on this? I&#8217;m a little beyond newbie but still learning php, MySQL and can get around a script okay. Was a COBOL programmer analyst for many years, so have an idea of process of a project.</p><p> If anyone knows of a calendar that does this already, I&#8217;d appreciate a link so I can take a look. Thanks. And thank you David for the great work on your blog.</p> ]]></content:encoded> </item> <item><title>By: Sam</title><link>http://davidwalsh.name/php-event-calendar/comment-page-1#comment-27976</link> <dc:creator>Sam</dc:creator> <pubDate>Mon, 19 Dec 2011 16:47:35 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4403#comment-27976</guid> <description>Did anyone figure out how to get it to print dates in the future months?
I have it printing the name of the person with an appointment, but it refuses to print in future months.</description> <content:encoded><![CDATA[<p>Did anyone figure out how to get it to print dates in the future months?<br
/> I have it printing the name of the person with an appointment, but it refuses to print in future months.</p> ]]></content:encoded> </item> <item><title>By: Raccoon</title><link>http://davidwalsh.name/php-event-calendar/comment-page-1#comment-27913</link> <dc:creator>Raccoon</dc:creator> <pubDate>Tue, 13 Dec 2011 18:43:21 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4403#comment-27913</guid> <description>Sharing my discover:
I change &quot;D&quot; for a &quot;d&quot; at the array part, but only event dates with two digit appear (10,11,12...) and later I try to change for an &quot;e&quot; and it works
&lt;code&gt;
$events = array();
$query = &quot;SELECT title, DATE_FORMAT(event_date,&#039;%Y-%m-%e&#039;) AS event_date FROM events WHERE event_date LIKE &#039;$year-$month%&#039;&quot;;
$result = mysql_query($query,$db_link) or die(&#039;cannot get results!&#039;);
while($row = mysql_fetch_assoc($result)) {
$events[$row[&#039;event_date&#039;]][] = $row;
}
&lt;/code&gt;</description> <content:encoded><![CDATA[<p>Sharing my discover:<br
/> I change &#8220;D&#8221; for a &#8220;d&#8221; at the array part, but only event dates with two digit appear (10,11,12&#8230;) and later I try to change for an &#8220;e&#8221; and it works<br
/> <code><br
/> $events = array();<br
/> $query = "SELECT title, DATE_FORMAT(event_date,'%Y-%m-%e') AS event_date FROM events WHERE event_date LIKE '$year-$month%'";<br
/> $result = mysql_query($query,$db_link) or die('cannot get results!');<br
/> while($row = mysql_fetch_assoc($result)) {<br
/> $events[$row['event_date']][] = $row;<br
/> }<br
/> </code></p> ]]></content:encoded> </item> <item><title>By: Adam</title><link>http://davidwalsh.name/php-event-calendar/comment-page-1#comment-27900</link> <dc:creator>Adam</dc:creator> <pubDate>Tue, 13 Dec 2011 04:05:20 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4403#comment-27900</guid> <description>Anyone know how to do a mouse over(or click) to show more info? So on the calendar it just shows title, but when you mouse over(or click the title) it shows &quot;where&quot;,&quot;who&quot;, etc?</description> <content:encoded><![CDATA[<p>Anyone know how to do a mouse over(or click) to show more info? So on the calendar it just shows title, but when you mouse over(or click the title) it shows &#8220;where&#8221;,&#8221;who&#8221;, etc?</p> ]]></content:encoded> </item> <item><title>By: Raccoon</title><link>http://davidwalsh.name/php-event-calendar/comment-page-1#comment-27898</link> <dc:creator>Raccoon</dc:creator> <pubDate>Tue, 13 Dec 2011 01:43:49 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4403#comment-27898</guid> <description>I really like your calendar code and I can see the calendar &amp; the controls but I can&#039;t see the events&#039; titles at the calendar cells.Could you please share another example of working code, just to see if I miss somethingThanks in advance for your help</description> <content:encoded><![CDATA[<p>I really like your calendar code and I can see the calendar &amp; the controls but I can&#8217;t see the events&#8217; titles at the calendar cells.</p><p>Could you please share another example of working code, just to see if I miss something</p><p>Thanks in advance for your help</p> ]]></content:encoded> </item> <item><title>By: Mihir Chhatre</title><link>http://davidwalsh.name/php-event-calendar/comment-page-1#comment-27838</link> <dc:creator>Mihir Chhatre</dc:creator> <pubDate>Tue, 06 Dec 2011 07:33:38 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4403#comment-27838</guid> <description>Hello,I am working on a multi-day event script! i have managed to use your *brilliant* script to display the data in one cell, but how would i use it to show a range? I Have the start &amp; end dates of the event.Is it possible? if so, how do i do it?Thank you,
MIhir.</description> <content:encoded><![CDATA[<p>Hello,</p><p>I am working on a multi-day event script! i have managed to use your *brilliant* script to display the data in one cell, but how would i use it to show a range? I Have the start &amp; end dates of the event.</p><p>Is it possible? if so, how do i do it?</p><p>Thank you,<br
/> MIhir.</p> ]]></content:encoded> </item> <item><title>By: mrugesh shah</title><link>http://davidwalsh.name/php-event-calendar/comment-page-1#comment-27832</link> <dc:creator>mrugesh shah</dc:creator> <pubDate>Sun, 04 Dec 2011 17:59:06 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4403#comment-27832</guid> <description>Inspite of reading above comments, I am still not able to display result inside the calendar cell.
I am able to fetch data successfully and it is showing perfect result outside. but not inside. Will you please help me ?following is my code.&lt;code&gt;&lt;?phpdate_default_timezone_set(&#039;Asia/Kolkata&#039;);
$tmonth=date(&quot;m&quot;);
$tyear=date(&quot;Y&quot;);
$events = array();$user_name = &quot;xyz&quot;;  /*this is sample data*/
$password = &quot;********&quot;;
$database = &quot;xyz&quot;;
$server = &quot;abcde&quot;;$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);if ($db_found) {/* draws a calendar */
function draw_calendar($month,$year){/* draw table */
$calendar = &#039;&#039;;/* table headings */
$headings = array(&#039;Sunday&#039;,&#039;Monday&#039;,&#039;Tuesday&#039;,&#039;Wednesday&#039;,&#039;Thursday&#039;,&#039;Friday&#039;,&#039;Saturday&#039;);
$calendar.= &#039;&#039;.implode(&#039;&#039;,$headings).&#039;&#039;;/* days and weeks vars now ... */
$running_day = date(&#039;w&#039;,mktime(0,0,0,$month,1,$year));
$days_in_month = date(&#039;t&#039;,mktime(0,0,0,$month,1,$year));
$days_in_this_week = 1;
$day_counter = 0;
$dates_array = array();/* row for week one */
$calendar.= &#039;&#039;;/* print &quot;blank&quot; days until the first of the current week */
for($x = 0; $x &lt; $running_day; $x++):
$calendar.= &#039;&#160;&#039;;
$days_in_this_week++;
endfor;/* keep going with days.... */
for($list_day = 1; $list_day &lt;= $days_in_month; $list_day++):
$calendar.= &#039;&#039;;
/* add in the day number */
$calendar.= &#039;&#039;.$list_day.&#039;&#039;;/** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !!  IF MATCHES FOUND, PRINT THEM !! **/$event_day = $year.&#039;-&#039;.$month.&#039;-&#039;.$list_day;
if(isset($events[$event_day])) {
foreach($events[$event_day] as $event) {
$calendar.= $event[&#039;tithi&#039;];
}
}
else {
$calendar.= str_repeat(&#039;&#160;&#039;,2);
}if(isset($events[$event_day])) { foreach($events[$event_day] as $event) { $calendar.= &#039;&#039;.  $event[&#039;title&#039;].&#039;&#039;; } } else { $calendar.= str_repeat(&#039;&#160;&#039;,2); }$calendar.= &#039;&#039;;
if($running_day == 6):
$calendar.= &#039;&#039;;
if(($day_counter+1) != $days_in_month):
$calendar.= &#039;&#039;;
endif;
$running_day = -1;
$days_in_this_week = 0;
endif;
$days_in_this_week++; $running_day++; $day_counter++;
endfor;/* finish the rest of the days in the week */
if($days_in_this_week &lt; 8):
for($x = 1; $x &lt;= (8 - $days_in_this_week); $x++):
$calendar.= &#039;&#160;&#039;;
endfor;
endif;/* final row */
$calendar.= &#039;&#039;;/* end the table */
$calendar.= &#039;&#039;;
/* all done, return result */
return $calendar;
}$SQL = &quot;SELECT tithi, DATE_FORMAT(tdate,&#039;%Y-%m-%d&#039;) AS tdate FROM date_table where tdate LIKE &#039;$tyear-$tmonth%&#039;&quot;;
$result = mysql_query($SQL);while ($row = mysql_fetch_assoc($result)) {
$events[$row[&#039;tdate&#039;]][] = $row;
}/* sample usages */
echo &#039;DEC 2011&#039;;
echo draw_calendar(12,2011);mysql_close($db_handle);}
else {
print &quot;Database NOT Found &quot;;
mysql_close($db_handle);
}?&gt;&lt;/code&gt;</description> <content:encoded><![CDATA[<p>Inspite of reading above comments, I am still not able to display result inside the calendar cell.<br
/> I am able to fetch data successfully and it is showing perfect result outside. but not inside. Will you please help me ?</p><p>following is my code.</p><p><code></p><p>&lt;?php</p><p>date_default_timezone_set(&#039;Asia/Kolkata&#039;);<br
/> $tmonth=date(&quot;m&quot;);<br
/> $tyear=date(&quot;Y&quot;);<br
/> $events = array();</p><p> $user_name = &quot;xyz&quot;;  /*this is sample data*/<br
/> $password = &quot;********&quot;;<br
/> $database = &quot;xyz&quot;;<br
/> $server = &quot;abcde&quot;;</p><p>$db_handle = mysql_connect($server, $user_name, $password);<br
/> $db_found = mysql_select_db($database, $db_handle);</p><p>if ($db_found) {</p><p>/* draws a calendar */<br
/> function draw_calendar($month,$year){</p><p> /* draw table */<br
/> $calendar = &#039;';</p><p> /* table headings */<br
/> $headings = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');<br
/> $calendar.= ''.implode('',$headings).'';</p><p> /* days and weeks vars now ... */<br
/> $running_day = date('w',mktime(0,0,0,$month,1,$year));<br
/> $days_in_month = date('t',mktime(0,0,0,$month,1,$year));<br
/> $days_in_this_week = 1;<br
/> $day_counter = 0;<br
/> $dates_array = array();</p><p> /* row for week one */<br
/> $calendar.= '';</p><p> /* print "blank" days until the first of the current week */<br
/> for($x = 0; $x &lt; $running_day; $x++):<br
/> $calendar.= &#039;&nbsp;';<br
/> $days_in_this_week++;<br
/> endfor;</p><p> /* keep going with days.... */<br
/> for($list_day = 1; $list_day &lt;= $days_in_month; $list_day++):<br
/> $calendar.= &#039;';<br
/> /* add in the day number */<br
/> $calendar.= ''.$list_day.'';</p><p> /** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !!  IF MATCHES FOUND, PRINT THEM !! **/</p><p> $event_day = $year.'-'.$month.'-'.$list_day;<br
/> if(isset($events[$event_day])) {<br
/> foreach($events[$event_day] as $event) {<br
/> $calendar.= $event['tithi'];<br
/> }<br
/> }<br
/> else {<br
/> $calendar.= str_repeat('&nbsp;',2);<br
/> }</p><p>if(isset($events[$event_day])) { foreach($events[$event_day] as $event) { $calendar.= ''.  $event['title'].''; } } else { $calendar.= str_repeat('&nbsp;',2); }</p><p> $calendar.= '';<br
/> if($running_day == 6):<br
/> $calendar.= '';<br
/> if(($day_counter+1) != $days_in_month):<br
/> $calendar.= '';<br
/> endif;<br
/> $running_day = -1;<br
/> $days_in_this_week = 0;<br
/> endif;<br
/> $days_in_this_week++; $running_day++; $day_counter++;<br
/> endfor;</p><p> /* finish the rest of the days in the week */<br
/> if($days_in_this_week &lt; 8):<br
/> for($x = 1; $x &lt;= (8 - $days_in_this_week); $x++):<br
/> $calendar.= &#039;&nbsp;';<br
/> endfor;<br
/> endif;</p><p> /* final row */<br
/> $calendar.= '';</p><p> /* end the table */<br
/> $calendar.= '';</p><p> /* all done, return result */<br
/> return $calendar;<br
/> }</p><p>$SQL = "SELECT tithi, DATE_FORMAT(tdate,'%Y-%m-%d') AS tdate FROM date_table where tdate LIKE '$tyear-$tmonth%'";<br
/> $result = mysql_query($SQL);</p><p>while ($row = mysql_fetch_assoc($result)) {<br
/> $events[$row['tdate']][] = $row;<br
/> }</p><p>/* sample usages */<br
/> echo 'DEC 2011';<br
/> echo draw_calendar(12,2011);</p><p>mysql_close($db_handle);</p><p>}<br
/> else {<br
/> print "Database NOT Found ";<br
/> mysql_close($db_handle);<br
/> }</p><p>?&gt;</p><p></code></p> ]]></content:encoded> </item> <item><title>By: Yulia</title><link>http://davidwalsh.name/php-event-calendar/comment-page-1#comment-27803</link> <dc:creator>Yulia</dc:creator> <pubDate>Thu, 01 Dec 2011 21:14:51 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4403#comment-27803</guid> <description>Thanks so much for your code! I have combined it with the jquery/ical calendar tutorial to get the event name to show up when you hover over a date, and it&#039;s perfect!</description> <content:encoded><![CDATA[<p>Thanks so much for your code! I have combined it with the jquery/ical calendar tutorial to get the event name to show up when you hover over a date, and it&#8217;s perfect!</p> ]]></content:encoded> </item> <item><title>By: Zak</title><link>http://davidwalsh.name/php-event-calendar/comment-page-1#comment-27723</link> <dc:creator>Zak</dc:creator> <pubDate>Wed, 23 Nov 2011 14:40:37 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4403#comment-27723</guid> <description>I still can’t get anything from the db. I did get it to connect, but can’t get anything on the calendar.</description> <content:encoded><![CDATA[<p>I still can’t get anything from the db. I did get it to connect, but can’t get anything on the calendar.</p> ]]></content:encoded> </item> <item><title>By: Jakfar</title><link>http://davidwalsh.name/php-event-calendar/comment-page-1#comment-27705</link> <dc:creator>Jakfar</dc:creator> <pubDate>Tue, 22 Nov 2011 16:45:27 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4403#comment-27705</guid> <description>&lt;code&gt;&lt;?php/* draws a calendar */
function draw_calendar($month,$year,$events = array()){
/* draw table */
$calendar = &#039;&#039;;/* table headings */
$headings = array(&#039;Minggu&#039;,&#039;Senin&#039;,&#039;Selasa&#039;,&#039;Rabu&#039;,&#039;Kamis&#039;,&#039;Jumat&#039;,&#039;Sabtu&#039;);
$calendar.= &#039;&#039;.implode(&#039;&#039;,$headings).&#039;&#039;;/* days and weeks vars now ... */
$running_day = date(&#039;w&#039;,mktime(0,0,0,$month,1,$year));
$days_in_month = date(&#039;t&#039;,mktime(0,0,0,$month,1,$year));
$days_in_this_week = 1;
$day_counter = 0;
$dates_array = array();/* row for week one */
$calendar.= &#039;&#039;;/* print &quot;blank&quot; days until the first of the current week */
for($x = 0; $x &lt; $running_day; $x++):
$calendar.= &#039;&#160;&#039;;
$days_in_this_week++;
endfor;/* keep going with days.... */
for($list_day = 1; $list_day &lt;= $days_in_month; $list_day++):
$calendar.= &#039;&#039;;
/* add in the day number */
if($list_day &lt; 10) {
$list_day = str_pad($list_day,2,&#039;0&#039;, STR_PAD_LEFT);
}
$calendar.= &#039;&#039;.$list_day.&#039;&#039;;
$event_day = $year.&#039;-&#039;.$month.&#039;-&#039;.$list_day;
if(isset($events[$event_day])) {
foreach($events[$event_day] as $event) {
$calendar.= &#039;&#039;.$event[&#039;title&#039;].&#039;&#039;;
}
}
else {
$calendar.= str_repeat(&#039;&#160;&#039;,2);
}
$calendar.= &#039;&#039;;
if($running_day == 6):
$calendar.= &#039;&#039;;
if(($day_counter+1) != $days_in_month):
$calendar.= &#039;&#039;;
endif;
$running_day = -1;
$days_in_this_week = 0;
endif;
$days_in_this_week++; $running_day++; $day_counter++;
endfor;/* finish the rest of the days in the week */
if($days_in_this_week &lt; 8):
for($x = 1; $x &lt;= (8 - $days_in_this_week); $x++):
$calendar.= &#039;&#160;&#039;;
endfor;
endif;/* final row */
$calendar.= &#039;&#039;;/* end the table */
$calendar.= &#039;&#039;;/** DEBUG **/
$calendar = str_replace(&#039;&#039;,&#039;&#039;.&quot;\n&quot;,$calendar);
$calendar = str_replace(&#039;&#039;,&#039;&#039;.&quot;\n&quot;,$calendar);
/* all done, return result */
return $calendar;
}function random_number() {
srand(time());
return (rand() % 7);
}/* date settings */$month = (int) ($_GET[&#039;month&#039;] ? $_GET[&#039;month&#039;] : date(&#039;m&#039;));
$year = (int)  ($_GET[&#039;year&#039;] ? $_GET[&#039;year&#039;] : date(&#039;Y&#039;));/* select month control */
$select_month_control = &#039;&#039;;
for($x = 1; $x &lt;= 12; $x++) {
if($x &lt; 10) {
$x = str_pad($x,2,&#039;0&#039;, STR_PAD_LEFT);
}
$select_month_control.= &#039;&#039;.date(&#039;F&#039;,mktime(0,0,0,$x,1,$year)).&#039;&#039;;
}
$select_month_control.= &#039;&#039;;/* select year control */
$year_range = 7;
$select_year_control = &#039;&#039;;
for($x = ($year-floor($year_range/2)); $x &lt;= ($year+floor($year_range/2)); $x++) {$select_year_control.= &#039;&#039;.$x.&#039;&#039;;
}
$select_year_control.= &#039;&#039;;/* &quot;next month&quot; control */
$next_month_link = &#039;&lt;a href=&quot;$year + 1).&#039;&quot; rel=&quot;nofollow&quot;&gt;Bulan Berikutnya &gt;&gt;&lt;/a&gt;&#039;;/* &quot;previous month&quot; control */
$previous_month_link = &#039;&lt;a href=&quot;$year - 1).&#039;&quot; rel=&quot;nofollow&quot;&gt;&lt;&lt;   Bulan Sebelumnya&lt;/a&gt;&#039;;/* bringing the controls together */
$controls = &#039;&#039;.$select_month_control.$select_year_control.&#039;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#039;.$previous_month_link.&#039;&#160;&#160;&#160;&#160;&#160;&#039;.$next_month_link.&#039; &#039;;$db_link = mysql_connect(&quot;localhost&quot;,&quot;root&quot;,&quot;&quot;); if (!$db_link) { die(&#039;Could not connect: &#039; . mysql_error()); }
mysql_select_db(&quot;events&quot;, $db_link);
$events = array();
$query = &quot;SELECT title, DATE_FORMAT( Tanggal, &#039;%Y-%m-%d&#039; ) AS Tanggal FROM EVENTS WHERE Tanggal LIKE &#039;$year-$month%&#039;&quot;;
$result = mysql_query($query,$db_link) or die(&#039;cannot get results!&#039;);
while($row = mysql_fetch_array($result)) {
$events[$row[&#039;Tanggal&#039;]][] = $row;
}echo &#039;&#039;.date(&#039;F&#039;,mktime(0,0,0,$month,1,$year)).&#039; &#039;.$year.&#039;&#039;;
echo &#039;&#039;.$controls.&#039;&#039;;
echo &#039;&#039;;
echo draw_calendar($month,$year,$events);
echo &#039;&#039;;
?&gt;&lt;/code&gt;</description> <content:encoded><![CDATA[<p><code>&lt;?php</p><p>/* draws a calendar */<br
/> function draw_calendar($month,$year,$events = array()){<br
/> /* draw table */<br
/> $calendar = &#039;';</p><p> /* table headings */<br
/> $headings = array('Minggu','Senin','Selasa','Rabu','Kamis','Jumat','Sabtu');<br
/> $calendar.= ''.implode('',$headings).'';</p><p> /* days and weeks vars now ... */<br
/> $running_day = date('w',mktime(0,0,0,$month,1,$year));<br
/> $days_in_month = date('t',mktime(0,0,0,$month,1,$year));<br
/> $days_in_this_week = 1;<br
/> $day_counter = 0;<br
/> $dates_array = array();</p><p> /* row for week one */<br
/> $calendar.= '';</p><p> /* print "blank" days until the first of the current week */<br
/> for($x = 0; $x &lt; $running_day; $x++):<br
/> $calendar.= &#039;&nbsp;';<br
/> $days_in_this_week++;<br
/> endfor;</p><p> /* keep going with days.... */<br
/> for($list_day = 1; $list_day &lt;= $days_in_month; $list_day++):<br
/> $calendar.= &#039;';<br
/> /* add in the day number */<br
/> if($list_day &lt; 10) {<br
/> $list_day = str_pad($list_day,2,&#039;0&#039;, STR_PAD_LEFT);<br
/> }<br
/> $calendar.= &#039;'.$list_day.'';</p><p> $event_day = $year.'-'.$month.'-'.$list_day;<br
/> if(isset($events[$event_day])) {<br
/> foreach($events[$event_day] as $event) {<br
/> $calendar.= ''.$event['title'].'';<br
/> }<br
/> }<br
/> else {<br
/> $calendar.= str_repeat('&nbsp;',2);<br
/> }<br
/> $calendar.= '';<br
/> if($running_day == 6):<br
/> $calendar.= '';<br
/> if(($day_counter+1) != $days_in_month):<br
/> $calendar.= '';<br
/> endif;<br
/> $running_day = -1;<br
/> $days_in_this_week = 0;<br
/> endif;<br
/> $days_in_this_week++; $running_day++; $day_counter++;<br
/> endfor;</p><p> /* finish the rest of the days in the week */<br
/> if($days_in_this_week &lt; 8):<br
/> for($x = 1; $x &lt;= (8 - $days_in_this_week); $x++):<br
/> $calendar.= &#039;&nbsp;';<br
/> endfor;<br
/> endif;</p><p> /* final row */<br
/> $calendar.= '';</p><p> /* end the table */<br
/> $calendar.= '';</p><p> /** DEBUG **/<br
/> $calendar = str_replace('',''."\n",$calendar);<br
/> $calendar = str_replace('',''."\n",$calendar);</p><p> /* all done, return result */<br
/> return $calendar;<br
/> }</p><p>function random_number() {<br
/> srand(time());<br
/> return (rand() % 7);<br
/> }</p><p>/* date settings */</p><p>$month = (int) ($_GET['month'] ? $_GET['month'] : date('m'));<br
/> $year = (int)  ($_GET['year'] ? $_GET['year'] : date('Y'));</p><p>/* select month control */<br
/> $select_month_control = '';<br
/> for($x = 1; $x &lt;= 12; $x++) {<br
/> if($x &lt; 10) {<br
/> $x = str_pad($x,2,&#039;0&#039;, STR_PAD_LEFT);<br
/> }<br
/> $select_month_control.= &#039;'.date('F',mktime(0,0,0,$x,1,$year)).'';<br
/> }<br
/> $select_month_control.= '';</p><p>/* select year control */<br
/> $year_range = 7;<br
/> $select_year_control = '';<br
/> for($x = ($year-floor($year_range/2)); $x &lt;= ($year+floor($year_range/2)); $x++) {</p><p> $select_year_control.= &#039;'.$x.'';<br
/> }<br
/> $select_year_control.= '';</p><p>/* "next month" control */<br
/> $next_month_link = '<a
href="$year + 1).'" rel="nofollow">Bulan Berikutnya &gt;&gt;</a>';</p><p>/* "previous month" control */<br
/> $previous_month_link = '<a
href="$year - 1).'" rel="nofollow">&lt;&lt;   Bulan Sebelumnya</a>';</p><p>/* bringing the controls together */<br
/> $controls = ''.$select_month_control.$select_year_control.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$previous_month_link.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$next_month_link.' ';</p><p>$db_link = mysql_connect("localhost","root",""); if (!$db_link) { die('Could not connect: ' . mysql_error()); }<br
/> mysql_select_db("events", $db_link);<br
/> $events = array();<br
/> $query = "SELECT title, DATE_FORMAT( Tanggal, '%Y-%m-%d' ) AS Tanggal FROM EVENTS WHERE Tanggal LIKE '$year-$month%'";<br
/> $result = mysql_query($query,$db_link) or die('cannot get results!');<br
/> while($row = mysql_fetch_array($result)) {<br
/> $events[$row['Tanggal']][] = $row;<br
/> }</p><p>echo ''.date('F',mktime(0,0,0,$month,1,$year)).' '.$year.'';<br
/> echo ''.$controls.'';<br
/> echo '';<br
/> echo draw_calendar($month,$year,$events);<br
/> echo '';<br
/> ?&gt;</code></p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 2/18 queries in 0.018 seconds using disk: basic
Object Caching 865/868 objects using disk: basic

Served from: davidwalsh.name @ 2012-02-09 04:20:54 -->
