<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" 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:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Mike Auteri</title>
	
	<link>http://www.mikeauteri.com</link>
	<description>eat... sleep... &lt;code /&gt;...</description>
	<lastBuildDate>Sun, 11 Sep 2011 13:37:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/mauteri" /><feedburner:info uri="mauteri" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Can’t believe it’s been 10 years…</title>
		<link>http://feedproxy.google.com/~r/mauteri/~3/xO7KT-Pv2_A/</link>
		<comments>http://www.mikeauteri.com/2011/09/11/cant-believe-its-been-10-years/#comments</comments>
		<pubDate>Sun, 11 Sep 2011 13:32:44 +0000</pubDate>
		<dc:creator>Mike Auteri</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.mikeauteri.com/?p=69</guid>
		<description><![CDATA[I thought it&#8217;d be a good idea to check out my old LiveJournal blog for the 9/11 post I wrote in 2001. But when I looked, my LJ account wasn&#8217;t created until December of that year. Apparently, in 2002 after the first anniversary, I tried to look for my 9/11 post, but realized that it [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mikeauteri.com/wp-content/uploads/2011/09/twintowers.jpg"><img class="alignleft size-medium wp-image-70" title="twintowers" src="http://www.mikeauteri.com/wp-content/uploads/2011/09/twintowers-247x300.jpg" alt="" width="247" height="300" /></a>I thought it&#8217;d be a good idea to check out my old LiveJournal blog for the 9/11 post I wrote in 2001. But when I looked, my LJ account wasn&#8217;t created until December of that year. Apparently, in 2002 after the first anniversary, I tried to look for my 9/11 post, but realized that it wasn&#8217;t there then too. So, in lieu of have my original 9/11 post, I will post my 2002 post that included a paper from 9/11/01.</p>
<p>For those that don&#8217;t know me all that well, I was in the first semester of my senior year in college when the attacks happened. So, without further ado, here&#8217;s my LJ post from 9/11/02&#8230;</p>
<p><span id="more-69"></span></p>
<table style="clear: both;" border="0">
<tbody>
<tr>
<td align="right"><strong>Current mood:</strong></td>
<td> hopeful</td>
</tr>
<tr>
<td align="right"><strong>Current music:</strong></td>
<td>super furry animals &#8211; it&#8217;s not the end of the world</td>
</tr>
</tbody>
</table>
<p><strong>and all the king&#8217;s horses and all the king&#8217;s men could not put humpty dumpty back together again&#8230;</strong><br />
i was thinking of doing a blast to the past and bring back an entry i did on september 11th 2001&#8230; but then i realized i didn&#8217;t have a livejournal that far back (mine started dececmber 7th, or so i found out tonight&#8230; for some reason i thought it was older than that, oh well). i did, however, remember writing something on that day. i had a paper i had to write for my senior seminar class. i decided, in memory of this tragic day in history to post this paper. it&#8217;s not extremely well written or even long due to the fact that this paper was the least of my worries on sad sad day (my professor didn&#8217;t hold it against us that most weren&#8217;t long or even done). i&#8217;m sure a lot of people are doing stuff like this in their journals today. just remember to give a moment of silence at 8:46 tomorrow morning. enjoy the read&#8230;</p>
<p><em>Michael J. Auteri<br />
Senior Seminar<br />
September 11, 2001<br />
Chapter 1: Examples of research in everyday life<br />
1.)<br />
Based on today’s events, I have chosen to write this brief paper on the catastrophic events that shook our nation today. I found myself woken up at quarter to ten to my roommate screaming the World Trade Center had been damaged. Not even completely processing what was said, I rushed into our living room to find a bunch of my friends sitting around the television watching reporters explain what had happened in New York City this morning. Throughout the rest of the day, I watched our television like I was glued to the couch. This, I believe, is a perfect example of how research has a significant impact on my life.<br />
When I first began watching CNN I had no idea what was going on. Was this a terrorist attack or simply just an accident? Over the course of the day as I watched the television, surfed the Internet, and spoke with other people, I was able to make some sense of the information the media was conveying to me. This task was quite frustrating. As a human being, I want all the answers upfront in the fastest way possible. However, this is not how it worked. Many things said were unclear and as the events of the day unfolded, some information was merely rumors. It was hard to decipher the “good” information from the “bad” information, like how many people were actually killed or who was responsible. The media did the best they could by figuring how many people were on the planes and how many (on average) worked in the buildings and how many were evacuated. This number, however, could be a way off estimate. The faceless cowards (terrorists) who were responsible were merely an assumption based on past events and threats.<br />
Today’s events have caused shock not only in this area, or this nation, but also around the world. I am not even sure if all of my friends and family are safe. So when this question asked how research impacts my current life, I have an answer that only requires one sentence. Research on this event impacts my life so greatly, that I am having difficulty writing this paper on research impacting my life.<br />
2.)<br />
I was once told, if you want to write something you have to know the subject you are writing about. This, however, can be more difficult than you may believe. If you do not have all the information on a subject, it is very difficult to write about it. This I found true on many news articles I found on newyorktimes.com on the Attack on America events today. I found many holes in the articles that still remain unexplained. This is normal for breaking news though. Reporters have deadlines and have to report something even if it is only a fragment of the story. I found a great deal of the research were quotes gathered from eyewitnesses and anything the media was able to get out of those in public relations (especially having to do with the airplane hijacks). The way this influences today’s society is how the media makes haste. Though it is not always accurate, reporters quickly make reports in order to keep people informed on new events as they immerge.</em></p>
<img src="http://feeds.feedburner.com/~r/mauteri/~4/xO7KT-Pv2_A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikeauteri.com/2011/09/11/cant-believe-its-been-10-years/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.mikeauteri.com/2011/09/11/cant-believe-its-been-10-years/</feedburner:origLink></item>
		<item>
		<title>Debt Ceiling</title>
		<link>http://feedproxy.google.com/~r/mauteri/~3/rM4nICkq5bg/</link>
		<comments>http://www.mikeauteri.com/2011/07/29/debt-ceiling/#comments</comments>
		<pubDate>Fri, 29 Jul 2011 10:42:46 +0000</pubDate>
		<dc:creator>Mike Auteri</dc:creator>
				<category><![CDATA[Comics]]></category>
		<category><![CDATA[comic]]></category>
		<category><![CDATA[debt ceiling]]></category>
		<category><![CDATA[politics]]></category>

		<guid isPermaLink="false">http://www.mikeauteri.com/?p=66</guid>
		<description />
			<content:encoded><![CDATA[<p><a href="http://www.mikeauteri.com/wp-content/uploads/2011/07/debt-ceiling.jpg"><img class="alignleft size-large wp-image-67" title="debt-ceiling" src="http://www.mikeauteri.com/wp-content/uploads/2011/07/debt-ceiling-926x1024.jpg" alt="Debt Ceiling" /></a></p>
<img src="http://feeds.feedburner.com/~r/mauteri/~4/rM4nICkq5bg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikeauteri.com/2011/07/29/debt-ceiling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.mikeauteri.com/2011/07/29/debt-ceiling/</feedburner:origLink></item>
		<item>
		<title>How to create a custom menu widget in WordPress</title>
		<link>http://feedproxy.google.com/~r/mauteri/~3/O9vHzxs3gmE/</link>
		<comments>http://www.mikeauteri.com/2011/06/19/how-to-create-a-custom-menu-widget-in-wordpress/#comments</comments>
		<pubDate>Sun, 19 Jun 2011 19:27:24 +0000</pubDate>
		<dc:creator>Mike Auteri</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.mikeauteri.com/?p=61</guid>
		<description><![CDATA[One of the relatively new things I like most about WordPress is the custom menus feature, which was first introduced in version 3.0. For pretty much all of my latest projects, I use the custom menu feature exclusively when it comes to menus. Many themes have menu locations that you can create your own menu [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mikeauteri.com/wp-content/uploads/2011/06/wordpress.jpg"><img class="alignleft size-medium wp-image-63" title="WordPress" src="http://www.mikeauteri.com/wp-content/uploads/2011/06/wordpress-300x199.jpg" alt="WordPress" width="300" height="199" /></a>One of the relatively new things I like most about WordPress is the custom menus feature, which was first introduced in version 3.0. For pretty much all of my latest projects, I use the custom menu feature exclusively when it comes to menus. Many themes have menu locations that you can create your own menu and then plug it in. For instance, my favorite theme, <a title="Genesis by StudioPress" href="http://www.studiopress.com/themes/genesis" target="_blank">Genesis by StudioPress</a>, offers 2 locations that I can make custom menus.</p>
<p>But for this one project I&#8217;m working on, I wanted to make a menu that can also appear in my sidebar as a widget. Hmmmm&#8230;</p>
<p><span id="more-61"></span></p>
<p>Sure, once I head over to the widgets area, I notice that Genesis has <strong>Genesis &#8211; Page Navigation Menu</strong>, but that&#8217;s only good if A.) You are building a child-theme from Genesis and/or B.) You are fine with just picking and choosing the pages you created in WordPress. One of the great features of Custom Menus is that you can link to pages/assets outside of your WordPress installation. So, let&#8217;s look at how we can bring widgets and custom menus together for some awesome development flexibility.</p>
<p>First, go to <strong>Menus</strong> under <strong>Appearance</strong> in the WordPress admin area. Once there, create a menu called <strong>Widget Navigation</strong> and add a few pages, links, or whatever to fill out the menu.</p>
<p>Once you have your navigation complete, save it and open your theme&#8217;s <strong>functions.php</strong> file and add this bit of code:</p>
<pre class="brush: php; gutter: true; first-line: 1">function sub_menu_widget() {
	wp_nav_menu( array('menu' =&gt; 'Sub Navigation' ));
}
wp_register_sidebar_widget(
	'menu_widget_1',
	'Submenu Widget',
	'sub_menu_widget',
	array(
		'description' =&gt; 'Custom widget menu'
	)
);</pre>
<p>Okay, let&#8217;s take a look at what&#8217;s going on here. We created a function called <strong>menu_widget</strong>, which when called outputs the Custom Menu we created called <strong>Widget Navigation</strong> (if you used a different name here, be sure to change the code to reflect the name you chose). In the second part of the code we register the widget. The first argument we pass is the widget ID I called <strong>menu_widget_1</strong>. This is used internally by WordPress to refer to your widget; it can basically be anything as log as it&#8217;s unique. The second argument is the name of your widget, which I called <strong>Widget Navigation</strong>. The third is our callback function which we went over already, and lastly, the fourth is an optional array. For this one, I simply defined the description. You don&#8217;t even need to include this, but I like having a description&#8230;</p>
<p>Once all this is in place and saved, head over to <strong>Appearance</strong> and then to <strong>Widgets</strong>. If you did everything correctly, you will find your widget under <strong>Available Widgets</strong>. Now just drag it over to one of your sidebars and you are good to go! If you have any questions, comments, or find any errors in my code, please let me know in the comments.</p>
<img src="http://feeds.feedburner.com/~r/mauteri/~4/O9vHzxs3gmE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikeauteri.com/2011/06/19/how-to-create-a-custom-menu-widget-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.mikeauteri.com/2011/06/19/how-to-create-a-custom-menu-widget-in-wordpress/</feedburner:origLink></item>
		<item>
		<title>My favorite “last songs”</title>
		<link>http://feedproxy.google.com/~r/mauteri/~3/5Dwq-KAc5dc/</link>
		<comments>http://www.mikeauteri.com/2010/09/27/my-favorite-last-songs/#comments</comments>
		<pubDate>Mon, 27 Sep 2010 05:00:11 +0000</pubDate>
		<dc:creator>Mike Auteri</dc:creator>
				<category><![CDATA[Music]]></category>
		<category><![CDATA[lists]]></category>
		<category><![CDATA[music]]></category>

		<guid isPermaLink="false">http://www.mikeauteri.com/?p=27</guid>
		<description><![CDATA[This is a picture of the band Pavement, whom I had the privilege of seeing last Tuesday evening. One of the songs in that night&#8217;s set list was a song called Fin, the last song on the Brighten the Corners album. While swaying and singing along to this great tune, I started thinking of other &#8220;Last Songs&#8221; on [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mikeauteri.com/wp-content/uploads/2010/09/2010-09-19-Williamsburg-Waterfront-Brooklyn-NY-3.jpg"><img class="alignleft size-medium wp-image-28" title="Pavement" src="http://www.mikeauteri.com/wp-content/uploads/2010/09/2010-09-19-Williamsburg-Waterfront-Brooklyn-NY-3-300x164.jpg" alt="" width="300" height="164" /></a>This is a picture of the band Pavement, whom I had the privilege of seeing last Tuesday evening. One of the songs in that night&#8217;s set list was a song called <em>Fin</em>, the last song on the <em>Brighten the Corners</em> album. While swaying and singing along to this great tune, I started thinking of other &#8220;Last Songs&#8221; on albums that were well placed as the last song.</p>
<p><span id="more-27"></span></p>
<p>Please keep in mind that this is my personal list, which is limited to my own taste in music. If you&#8217;d like to add some of your own in the comments, please do. So without any further ado, here&#8217;s my list in alphabetical order by artist.</p>
<ul>
<li>The Arcade Fire / Neon Bible / My Body Is A Cage</li>
<li>The Beatles / Abbey Road / Because*</li>
<li>Belle &amp; Sebastian / If You&#8217;re Feeling Sinister / Judy And The Dream Of Horses</li>
<li>Blanche / If We Can&#8217;t Trust The Doctors&#8230; / Someday</li>
<li>Built To Spill / Keep It Like A Secret / Broken Chairs</li>
<li>Catherine Wheel / Happy Days / Kill My Soul</li>
<li>Guns N&#8217; Roses / Appetite For Destruction / Rocket Queen</li>
<li>The Kinks / The Village Green Preservation Society / People Take Pictures Of Each Other</li>
<li>Led Zeppelin / Led Zeppelin IV / When The Levee Breaks</li>
<li>Modest Mouse / The Moon &amp; Antarctica / What People Are Made Of</li>
<li>Muse / Black Holes And Revelations / Knights Of Cydonia</li>
<li>Nirvana / In Utero / All Apologies</li>
<li>Pavement / Crooked Rain, Crooked Rain / Fillmore Jive</li>
<li>Pavement / Brighten The Corners / Fin</li>
<li>Pixies / Doolittle / Gouge Away</li>
<li>Pulp / His &#8216;n&#8217; Hers / Razzmatazz**</li>
<li>Radiohead / Pablo Honey / Blow Out***</li>
<li>Radiohead / The Bends / Street Spirit (Fade Out)</li>
<li>Elliott Smith / Either/Or / Say Yes</li>
<li>Supergrass / In It For The Money / Sometimes I Make You Sad</li>
<li>Television / Marquee Moon / Torn Curtain</li>
<li>Weezer / Weezer (Blue Album) / Only In Dreams</li>
</ul>
<p>* Not the last song, but the last song on the first side of Abbey Road is you are listening to it on record. It has a &#8220;last song&#8221; feel to it for me.<br />
** This is the last song on the US version of the album, apparently. None the less, it has that last song feel.<br />
*** Creep (Clean Version) doesn&#8217;t count!</p>
<img src="http://feeds.feedburner.com/~r/mauteri/~4/5Dwq-KAc5dc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikeauteri.com/2010/09/27/my-favorite-last-songs/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.mikeauteri.com/2010/09/27/my-favorite-last-songs/</feedburner:origLink></item>
		<item>
		<title>Meow?!</title>
		<link>http://feedproxy.google.com/~r/mauteri/~3/IKdedi6q0ZA/</link>
		<comments>http://www.mikeauteri.com/2010/07/10/meow/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 02:32:10 +0000</pubDate>
		<dc:creator>Mike Auteri</dc:creator>
				<category><![CDATA[Snuggle Bunny]]></category>
		<category><![CDATA[comic]]></category>

		<guid isPermaLink="false">http://www.mikeauteri.com/?p=18</guid>
		<description><![CDATA[My inspiration for this one came from when my wife&#8217;s lovely cat, Gizmo, peed on me 5 and a half years ago. Steph and I were casually dating about a week at that point. So basically, Gizmo claimed me as his before she did.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mikeauteri.com/wp-content/uploads/2010/07/sb2.png"><img class="alignnone size-full wp-image-21" title="sb2" src="http://www.mikeauteri.com/wp-content/uploads/2010/07/sb2-e1278728800952.png" alt="" width="600" height="244" /></a></p>
<p><span id="more-18"></span></p>
<p>My inspiration for this one came from when my wife&#8217;s lovely cat, Gizmo, peed on me 5 and a half years ago. Steph and I were casually dating about a week at that point. So basically, Gizmo claimed me as his before she did.</p>
<img src="http://feeds.feedburner.com/~r/mauteri/~4/IKdedi6q0ZA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikeauteri.com/2010/07/10/meow/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.mikeauteri.com/2010/07/10/meow/</feedburner:origLink></item>
		<item>
		<title>Stupid Bunny</title>
		<link>http://feedproxy.google.com/~r/mauteri/~3/i2AIs1Q70Ac/</link>
		<comments>http://www.mikeauteri.com/2010/06/27/stupid-bunny/#comments</comments>
		<pubDate>Sun, 27 Jun 2010 22:47:44 +0000</pubDate>
		<dc:creator>Mike Auteri</dc:creator>
				<category><![CDATA[Snuggle Bunny]]></category>
		<category><![CDATA[comic]]></category>

		<guid isPermaLink="false">http://www.mikeauteri.com/?p=14</guid>
		<description />
			<content:encoded><![CDATA[<p><a href="http://www.mikeauteri.com/wp-content/uploads/2010/06/sb1.png"><img class="size-full wp-image-15 alignnone" title="sb1" src="http://www.mikeauteri.com/wp-content/uploads/2010/06/sb1-e1277678733742.png" alt="snuggle bunny" width="600" height="244" /></a></p>
<img src="http://feeds.feedburner.com/~r/mauteri/~4/i2AIs1Q70Ac" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikeauteri.com/2010/06/27/stupid-bunny/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.mikeauteri.com/2010/06/27/stupid-bunny/</feedburner:origLink></item>
		<item>
		<title>Create a dynamic calendar with PHP &amp; jQuery</title>
		<link>http://feedproxy.google.com/~r/mauteri/~3/tcoOOMTCPZs/</link>
		<comments>http://www.mikeauteri.com/2010/06/27/create-a-dynamic-calendar-with-php-jquery/#comments</comments>
		<pubDate>Sun, 27 Jun 2010 15:43:08 +0000</pubDate>
		<dc:creator>Mike Auteri</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.mikeauteri.com/?p=6</guid>
		<description><![CDATA[So I&#8217;m working on a project where I have to put together a calendar feature that will eventually hold various tasks. So after a looking around the Internet, I found this Simple PHP Calendar to help me get the ball rolling. For the record, I don&#8217;t love the code provided here, but it was really [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mikeauteri.com/wp-content/uploads/2010/06/calendar.jpg"><img class="alignleft size-thumbnail wp-image-9" title="PHP/jQuery Calendar" src="http://www.mikeauteri.com/wp-content/uploads/2010/06/calendar-150x150.jpg" alt="" width="150" height="150" /></a>So I&#8217;m working on a project where I have to put together a calendar feature that will eventually hold various tasks. So after a looking around the Internet, I found this <a title="Simple PHP Calendar" href="http://php.about.com/od/finishedphp1/ss/php_calendar.htm" target="_blank">Simple PHP Calendar</a> to help me get the ball rolling. For the record, I don&#8217;t <em>love</em> the code provided here, but it was really easy to follow and there were some areas where I could improve the code. So yes, I&#8217;m going to show you some of the code that I lifted (and edited slightly) from mentioned blog post, plus I&#8217;ll show you the jQuery/JavaScript code I wrote to switch between months. I&#8217;ll try and explain as best I can from start to finish. And please, if you have any further improvements to my code, let me know in the comments. I&#8217;m not going to cover any ajax stuff in this post, but I&#8217;m thinking maybe I will follow up with it in a part 2 eventually.<br />
<span id="more-6"></span></p>
<h3>The Back-End: PHP</h3>
<p>So basically we are going to create a function called <strong>getCalendar()</strong>, which of course will look something like this&#8230;</p>
<pre class="brush: php; gutter: true; first-line: 1">function getCalendar() {
	//our code will go here
}</pre>
<p>Now that we got how to write a function out of the way, let&#8217;s move on to the guts of the code that will replace my little <strong>//our code will go here</strong> comment within the function. So first, let&#8217;s take a look at the variables we need.</p>
<pre>
<pre class="brush: php; gutter: true; first-line: 1">function getCalendar() {
	$day = date('d');
	$month = date('m');
	$year = date('Y');
	$first_day = mktime(0,0,0,$month, 1, $year);
	$title = date('M', $first_day);
	$day_of_week = date('D', $first_day);</pre>
</pre>
<p>Ok, so obviously we&#8217;ll be using the handy <strong>date()</strong> function. And by passing different arguments like <strong>d</strong> for day, <strong>m</strong> for month, and <strong>Y</strong> for year, we can grab all that we need to start building a calendar that reflects the current date. That last variable, <strong>$day_of_week</strong> will be used in the next section of code to figure out which day the first of the month falls on. We&#8217;ll be using a switch statement to start figuring that out.</p>
<pre>
<pre class="brush: php; gutter: true; first-line: 1">	switch($day_of_week) {
		case "Sun": $blank = 0; break;
		case "Mon": $blank = 1; break;
		case "Tue": $blank = 2; break;
		case "Wed": $blank = 3; break;
		case "Thu": $blank = 4; break;
		case "Fri": $blank = 5; break;
		case "Sat": $blank = 6; break;
	}
	$days_in_month = cal_days_in_month(0, $month, $year);</pre>
</pre>
<p>The next bit of markup you might want to edit. Some parts of this table can be done better with CSS. Please take note of the id&#8217;s and classes I use here. I added them in from the original code in order to write the jQuery functions. I also added in the <strong>$row_count</strong> variable so I will always have enough rows to fill in all the dates for every month. Anyway, here is the last bit of code you need to add to the calendar.</p>
<pre>
<pre class="brush: php; gutter: true; first-line: 1">	echo "&lt;table id='calendar' border='1' cellspacing='0' width='280'&gt;";
	echo "&lt;tr&gt;&lt;th id='prev'&gt;&lt;&lt;/th&gt;&lt;th colspan='5'&gt; &lt;span id='month'&gt;$title&lt;/span&gt;, &lt;span id='year'&gt;$year&lt;/span&gt;&lt;/th&gt;&lt;th id='next'&gt;&gt;&lt;/th&gt;&lt;/tr&gt;";
	echo "&lt;tr&gt;&lt;td width='42'&gt;S&lt;/td&gt;&lt;td width='42'&gt;M&lt;/td&gt;&lt;td width='42'&gt;T&lt;/td&gt;&lt;td width='42'&gt;W&lt;/td&gt;&lt;td width='42'&gt;T&lt;/td&gt;&lt;td width='42'&gt;F&lt;/td&gt;&lt;td width='42'&gt;S&lt;/td&gt;&lt;/tr&gt;";
	$day_count = 1;
	echo "&lt;tr&gt;";
	while ( $blank &gt; 0 ) {
	echo "&lt;td class='day'&gt;&lt;/td&gt;";
		$blank = $blank-1;
		$day_count++;
	}
	$day_num = 1;
	$row_count = 1;
	while ( $day_num &lt;= $days_in_month ) {
		echo "&lt;td class='day'&gt; $day_num &lt;/td&gt;";
		$day_num++;
		$day_count++;
		if ($day_count &gt; 7) {
			echo "&lt;/tr&gt;&lt;tr&gt;";
			$day_count = 1;
			$row_count++;
		}
	}
	while ($row_count &lt;=6 ) {
		echo "&lt;td class='day'&gt;&lt;/td&gt;";
		$day_count++;
		if ($day_count &gt; 7) {
			$day_count = 1;
			$row_count++;
			$row_count &lt;=6 ? print('&lt;/tr&gt;&lt;tr&gt;') : print('');
		}
	}
	echo "&lt;/tr&gt;&lt;/table&gt;";
}</pre>
</pre>
<p>Now all you have to do is call the function on a page.</p>
<pre>
<pre class="brush: php; gutter: true; first-line: 1">echo getCalendar();</pre>
</pre>
<p>Now let&#8217;s move onto the really fun jQuery part.</p>
<h3>The Front-End: jQuery</h3>
<p>As you probably know, jQuery is an incredibly popular and powerful JavaScript library that lets you do some incredible things using very little code. For the calendar, I wrote 2 functions that use the <strong>#next</strong> and <strong>#prev</strong> id&#8217;s in the HTML of my calendar to go forward and backward. Anyway, before we get into the big functions, here&#8217;s a quick styling function I wrote to grey out the unused boxes in the calendar. Also remember to place all this code in document ready, which looks like this:</p>
<pre>
<pre class="brush: javascript; gutter: true; first-line: 1">$(function() {
	//jQuery code goes here
});</pre>
</pre>
<p>Okay, so for my grey boxes, place this code in document ready.</p>
<pre>
<pre class="brush: javascript; gutter: true; first-line: 1">$('.day').each(function() {
	$(this).text() == '' ? $(this).css('background', '#ccc') : $(this).css('background', '#fff');
});</pre>
</pre>
<p>Now lets create the JavaScript arrays for months and days. We also need a variable to grab today&#8217;s date.</p>
<pre>
<pre class="brush: javascript; gutter: true; first-line: 1"> var months = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
 var days = new Array('S', 'M', 'T', 'W', 'T', 'F', 'S');
 var date = new Date();</pre>
</pre>
<p>Here&#8217;s the last bit of code you need: 2 jQuery click functions to take you forward and backward. This is all done in JavaScript/jQuery, so the page never needs to reload. If you do reload the page, it will take you back to the current month. If you want it to hold onto the month/year you were looking at, I suggest creating/updating a cookie. Maybe I&#8217;ll cover how to do that too in part 2.</p>
<pre>
<pre class="brush: javascript; gutter: true; first-line: 1">$('#next').click(function() {
	//gets current year from page
	var curMon = $('#month').text();
	for(var i in months) {
		if(months[i] == curMon) {
			//if not dec, increment i
			if(i != 11) {
				i++;
			} else {
			//else, back to jan and increment year
				i = 0;
				var curYear = $('#year').text();
				curYear = parseInt(curYear) + 1;
				curYear = curYear.toString();
				$('#year').text(curYear);
			}
			$('#month').html(months[i]);
			var yy = parseInt( $('#year').text() );
			var days = daysInMonth(i, yy);
			//clear all the dates
			$('.day').each(function() {
				$(this).text('');
			});
			var firstDay = new Date(months[i]+', 1 ' + yy);
			firstDay = firstDay.getDay();
			var j = 1;
			while(j &lt;= days) {
				//fills in dates starting in the correct spot
				$('.day').eq(firstDay).text(j);
				firstDay++;
				j++;
			}
		}
	}
	//grey out unused boxes again
	$('.day').each(function() {
		$(this).text() == '' ? $(this).css('background', '#ccc') : $(this).css('background', '#fff');
	});
});
$('#prev').click(function() {
	var curMon = $('#month').text();
	for(var i in months) {
		if(months[i] == curMon) {
			if(i != 0) {
				i--;
			} else {
				i = 11;
				var curYear = $('#year').text();
				curYear = parseInt(curYear) - 1;
				curYear = curYear.toString();
				$('#year').text(curYear);
			}
			$('#month').html(months[i]);
			var yy = parseInt( $('#year').text() );
			var days = daysInMonth(i, yy);
			$('.day').each(function() {
				$(this).text('');
			});
			var firstDay = new Date(months[i]+', 1 ' + yy);
			firstDay = firstDay.getDay();
			var j = 1;
			while(j &lt;= days) {
				$('.day').eq(firstDay).text(j);
				firstDay++;
				j++;
			}
		}
	}
	$('.day').each(function() {
		$(this).text() == '' ? $(this).css('background', '#ccc') : $(this).css('background', '#fff');
	});
});
//this little function returns how many days or in each month
function daysInMonth(m, y) {
return new Date(y, m+1, 0).getDate();
}</pre>
</pre>
<p>So that&#8217;s it. I added some comments in the first function so you can follow along. I&#8217;ve also included a link to a <a href="http://www.mikeauteri.com/examples/calendar.php">working model of the calendar</a>. Just view source to see all the jQuery and (minimal) CSS.</p>
<img src="http://feeds.feedburner.com/~r/mauteri/~4/tcoOOMTCPZs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikeauteri.com/2010/06/27/create-a-dynamic-calendar-with-php-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.mikeauteri.com/2010/06/27/create-a-dynamic-calendar-with-php-jquery/</feedburner:origLink></item>
	</channel>
</rss>

