<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>Amped about Web Standards &#187; php</title>
	<atom:link href="http://www.ampedwebstandards.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ampedwebstandards.com</link>
	<description>Discussion, code examples, and tutorials on web standards and web programming.</description>
	<lastBuildDate>Tue, 23 Feb 2010 10:05:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Tutorial: Dynamic slideshow with PHP &amp; JQuery</title>
		<link>http://www.ampedwebstandards.com/2009/03/16/tutorial-dynamic-image-slideshow-with-php-jquery/</link>
		<comments>http://www.ampedwebstandards.com/2009/03/16/tutorial-dynamic-image-slideshow-with-php-jquery/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 08:39:25 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.ampedwebstandards.com/?p=95</guid>
		<description><![CDATA[When I set out to add database driven player info at NuggetsHoops.com, I knew that I wanted to include code that would display some of the many images that I had set aside for each NBA player. I also knew that I would continue to add new pictures. Application code that could easily display old [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ampedwebstandards.com%2F2009%2F03%2F16%2Ftutorial-dynamic-image-slideshow-with-php-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ampedwebstandards.com%2F2009%2F03%2F16%2Ftutorial-dynamic-image-slideshow-with-php-jquery%2F&amp;source=aswitzer&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>When I set out to add database driven player info at <a title="NuggetsHoops" href="http://nuggetshoops.com">NuggetsHoops.com</a>, I knew that I wanted to include code that would display some of the many images that I had set aside for each NBA player. I also knew that I would continue to add new pictures. Application code that could easily display old and new images, without additional effort for each added image would work best.</p>
<p>I had already written PHP code that could look at a folder and create a list of images to be displayed. When I ran across the powerful<a title="jQuery Cycle Plugin" href="http://jquery.malsup.com/cycle/"> jQuery Cycle Plugin</a>, I had found a great way to display them.</p>
<p>Let&#8217;s get coding. This tutorial depends on PHP 5, jQuery 1.2.3 or later, jQuery Cycle Plugin version 2.51 or later.
<ul>
<li>I&#8217;ll assume you already have <a href="http://apache.org/">Apache</a> and <a href="http://www.php.net/downloads.php">PHP</a> setup and running. Make sure you have a recent version of PHP 5.</li>
<li><a title="jQuery Homepage" href="http://jquery.com/">Download jQuery</a></li>
<li><a title="Download jQuery Cycle Plugin" href="http://jquery.malsup.com/cycle/download.html">Download jQuery Cycle Plugin</a></li>
</ul>
<p>Add the following Javascript to your PHP/HTML to enable and call the Cycle Plugin:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="javascript"><div class="devcodeoverflow"><ol><li>&lt;script src=&quot;/scripts/jquery-1.3.2.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</li><li>&lt;script src=&quot;/scripts/jquery.cycle.all.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</li><li>&lt;script type=&quot;text/javascript&quot;&gt;</li><li>$(document).ready(function(){</li><li>	$('#myslides').cycle({</li><li>		fit: 1</li><li>	});</li><li>});</li><li>&lt;/script&gt;</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Note that there are <a href="http://www.malsup.com/jquery/cycle/options.html">many options</a> and <a href="http://www.malsup.com/jquery/cycle/browser.html">styles of animation</a> provided by the powerful Cycle plugin.</p>
<p>Add the following PHP to iterate over any folder and dynamically generate img tags using any images found in the folder:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="php"><div class="devcodeoverflow"><ol><li>$directory = 'images/players/' . $row['imageName']; </li><li>try {&nbsp;&nbsp;&nbsp;&nbsp;</li><li>	// Styling for images</li><li>	echo &quot;&lt;div id=\&quot;myslides\&quot;&gt;&quot;;</li><li>	foreach ( new DirectoryIterator(&quot;../&quot; . $directory) as $item ) {			</li><li>		if ($item-&gt;isFile()) {</li><li>			$path = &quot;/&quot; . $directory . &quot;/&quot; . $item;</li><li>			echo &quot;&lt;img src=\&quot;&quot; . $path . &quot;\&quot; /&gt;&quot;;</li><li>		}</li><li>	}</li><li>	echo &quot;&lt;/div&gt;&quot;;</li><li>}</li><li>catch(Exception $e) {</li><li>	echo 'No images found for this player.&lt;br /&gt;';</li><li>}</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Any img tags within an HTML element of class &#8216;myslides&#8217; (or whatever you initialized the Cycle plugin with in the Javascript) will have the slideshow behavior added to it. The $row array on line 1 is referencing a database query result, but could be set in a number of ways for your specific needs. The DirectoryIterator reference on line 5 is a builtin class in PHP5.</p>
<p>Here&#8217;s the CSS to style the images being displayed in the slideshow:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="css"><div class="devcodeoverflow"><ol><li>#myslides {</li><li>width: 340px;</li><li>float: right;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;padding: 0;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;margin:&nbsp;&nbsp;0 auto;</li><li>margin-top: 20px;</li><li>} </li><li>&nbsp;</li><li>#myslides img {</li><li>&nbsp;&nbsp;&nbsp;&nbsp;padding: 10px;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;border:&nbsp;&nbsp;1px solid rgb(100,100,100);</li><li>&nbsp;&nbsp;&nbsp;&nbsp;background-color: rgb(230,230,230);</li><li>&nbsp;&nbsp;&nbsp;&nbsp;width: 320px;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;top:&nbsp;&nbsp;0;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;left: 0</li><li>}</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>So, there&#8217;s a very quick walk thru a working example to generate a dynamic slideshow from any folder of images. If you&#8217;d like a full download of the code, or any further explanation, please leave a comment!</p>
<p>You can see this code in action by just clicking on any player&#8217;s name at the  <a href="http://www.nuggetshoops.com/roster.php">NuggetsHoops.com Roster page</a>.</p>
<h2>New &#8211; download the code for this Tutorial</h2>
<p><a class="downloadlink" href="http://www.ampedwebstandards.com/download/1" title="Version1.0 downloaded 888 times" >Code for Dynamic Image Slideshow with PHP and JQuery (888)</a></p>
<p><a href="http://www.ampedwebstandards.com/demos/dynamic-image-slideshow-php-jquery/">Demo</a><br />
<br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ampedwebstandards.com/2009/03/16/tutorial-dynamic-image-slideshow-with-php-jquery/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
		<item>
		<title>Coding quick reference guides</title>
		<link>http://www.ampedwebstandards.com/2007/10/05/coding-quick-reference-guides/</link>
		<comments>http://www.ampedwebstandards.com/2007/10/05/coding-quick-reference-guides/#comments</comments>
		<pubDate>Fri, 05 Oct 2007 06:19:01 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[Microformats]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.ampedwebstandards.com/2007/10/05/coding-quick-reference-guides/</guid>
		<description><![CDATA[Web developers need to have a tons of languages and syntaxes in their short term memories &#8211; HTML, CSS, Javascript, PHP, MySQL, Microformats, Regular Expressions &#8211; its a lot to know and remember. When I studied for big exams in college, my favorite technique was to create an all encompassing one-page sheet with everything I [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ampedwebstandards.com%2F2007%2F10%2F05%2Fcoding-quick-reference-guides%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ampedwebstandards.com%2F2007%2F10%2F05%2Fcoding-quick-reference-guides%2F&amp;source=aswitzer&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Web developers need to have a tons of languages and syntaxes in their short term memories &#8211; HTML, CSS, Javascript, PHP, MySQL, Microformats, Regular Expressions &#8211; its a lot to know and remember.</p>
<p>When I studied for big exams in college, my favorite technique was to create an all encompassing one-page sheet with everything I needed to know for that exam. The act of creating that page was the process of reviewing for the exam, and then I had something to refer to right up until exam time, aid in the memorization.</p>
<p>As web developers trying to keep up with all of the technologies in our toolbox &#8211; we need all the help when can get. Dave Child has put together a thorough and impressive set of &#8220;cheat sheets&#8221;  that I highly recommend.</p>
<p>Head on over to Dave&#8217;s site <a href="http://addedbytes.com/cheat-sheets" title="Coding Cheat Sheets" target="_blank">addedbytes.com/cheat-sheets</a> to download the ones you need. Print and pin them up next to your monitor for the next time you can&#8217;t remember the syntax for the various box model attributes in CSS. <img src='http://www.ampedwebstandards.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  If you find them useful, don&#8217;t forget to get Dave something from his <a href="http://www.amazon.co.uk/exec/obidos/registry/3JVSYKW57HEYM" title="Amazon Wish List" target="_blank">Amazon wish list</a> as a way to say thanks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ampedwebstandards.com/2007/10/05/coding-quick-reference-guides/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating microformat hCalendar events with PHP</title>
		<link>http://www.ampedwebstandards.com/2007/03/29/creating-microformat-hcalendar-events-with-php/</link>
		<comments>http://www.ampedwebstandards.com/2007/03/29/creating-microformat-hcalendar-events-with-php/#comments</comments>
		<pubDate>Thu, 29 Mar 2007 07:13:17 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Microformats]]></category>
		<category><![CDATA[hCalendar]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.ampedwebstandards.com/2007/03/29/creating-microformat-hcalendar-events-with-php/</guid>
		<description><![CDATA[I&#8217;ve run an NBA fansite called NuggetsHoops.com since 1995. With equal passions for the Denver Nuggets and web design, I&#8217;ve poured a lot of time and effort into the website. Every month, there are more and more &#8220;blogs&#8221; dedicated to the Denver Nuggets, as their popularity has grown over the past few seasons with the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ampedwebstandards.com%2F2007%2F03%2F29%2Fcreating-microformat-hcalendar-events-with-php%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ampedwebstandards.com%2F2007%2F03%2F29%2Fcreating-microformat-hcalendar-events-with-php%2F&amp;source=aswitzer&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I&#8217;ve run an NBA fansite called <a title="NuggetsHoops.com - a Denver Nuggets fansite" href="http://nuggetshoops.com" target="_blank">NuggetsHoops.com</a> since 1995. With equal passions for the Denver Nuggets and web design, I&#8217;ve   poured a lot of time and effort into the website. Every month, there are more and more &#8220;blogs&#8221; dedicated to the Denver Nuggets, as their popularity has grown over the past few seasons with the additions of NBA superstars Carmelo Anthony and Allen Iverson to the roster. So, partly to be different, and partly to create interesting web development challenges, I usually focus my fansite on fun features that provide Nuggets fans with information presented in unique and hopefully useful ways.</p>
<p>One of those features is a fairly standard <a title="NuggetsHoops Schedule &#038; Results" href="http://www.nuggetshoops.com/schedule.php" target="_blank">Schedule &#038; Results</a> page that shows how the Nugget fared in every game of the season, along with the remaining games on the season&#8217;s schedule. What makes it currently unique is the fact that each remaining game on the schedule is an <a title="hCalendar Microformat Wiki" href="//microformats.org/wiki/hcalendar" target="_blank">hCalendar Microformat</a>. A future article will show you exactly how you can take advantage of this feature, but for now, I will assume you know how to utilize Microformats, and you are here to see how to create them as a web developer.</p>
<p>For this example, we are going to access a MySQL database with information about remaining games, then use PHP code to dynamically display it. At the same time we are outputting the dynamic schedule information, we are going to add the very useful hCalendar microformat. The purpose of this article is not to teach you <a title="PHP.net" href="http://php.net" target="_blank">PHP</a>, <a title="MySQL AB Developer Zone" href="http://www.mysql.org/" target="_blank">MySQL</a>, or even <a title="CSS from W3 Schools" href="http://www.w3schools.com/css/default.asp" target="_blank">CSS</a> &#8211; the focus here is a real world example that you can add microformat markup to.</p>
<p>First,  let&#8217;s perform some date logic to get the current date, then compare it with dates in a schedule database table to get the remaining games for the current season.</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="php"><div class="devcodeoverflow"><ol><li>&lt;?php</li><li>// Display Remaining games</li><li>$today = getdate();</li><li>$cmpDate = $today['year'] . '-' . $today['mon'] . '-' .</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $today['mday'] . ' ' .</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $today['hours'] . ':' . $today['minutes'];</li><li>$monthDisplayed = 0;</li><li>&nbsp;</li><li>$sql = &quot;SELECT * from schedule where start_date &gt; '&quot;.</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$cmpDate.&quot;'&quot;;</li><li>$result=db_query($sql);</li><li>?&gt;</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Now we have a list of rows to iterate over and display. This example is already in the middle of an HTML table, so we&#8217;re just going to create new tr tags for each remaining game.<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="php"><div class="devcodeoverflow"><ol><li>&lt;?php</li><li>while ($row = mysql_fetch_array($result)) {</li><li>&nbsp;&nbsp;$gameDate = date('D j', strtotime($row['start_date']));</li><li>&nbsp;&nbsp;$gameTime = date('g:i A', strtotime($row['start_date']));</li><li>&nbsp;&nbsp;$gameEnd = date('g:i A',</li><li>&nbsp;&nbsp;strtotime('+2 hours 30 minutes',</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strtotime($row['start_date'])));</li><li>&nbsp;&nbsp;$month = date('F', strtotime($row['start_date']));</li><li>&nbsp;</li><li>&nbsp;&nbsp;$dtstartM = date('Y-m-dTG:i:sO',</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strtotime($row['start_date']));</li><li>&nbsp;&nbsp;$dendM = date('Y-m-dTG:i:sO',</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strtotime('+2 hours 30 minutes',</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strtotime($row['start_date'])));</li><li>&nbsp;</li><li>&nbsp;&nbsp;if ($month != $currMonth)</li><li>&nbsp;&nbsp;&nbsp;&nbsp;$monthDisplayed = 0;</li><li>&nbsp;</li><li>&nbsp;&nbsp;// Check if we need to display a new month header row</li><li>&nbsp;&nbsp;if (!$monthDisplayed) {</li><li>&nbsp;&nbsp;&nbsp;&nbsp;$currMonth = $month;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;$monthDisplayed = 1;</li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;echo '&lt;tr class=&quot;rowHeaderSchedule&quot;&gt;';</li><li>&nbsp;&nbsp;&nbsp;&nbsp;echo '&lt;td&gt;' . strtoupper($month) . '&lt;/td&gt;';</li><li>&nbsp;&nbsp;&nbsp;&nbsp;echo '&lt;td&gt;OPPONENT&lt;/td&gt;';</li><li>&nbsp;&nbsp;&nbsp;&nbsp;echo '&lt;td&gt;&lt;div align=&quot;left&quot;&gt;TIME (MT)&lt;/div&gt;&lt;/td&gt;';</li><li>&nbsp;&nbsp;&nbsp;&nbsp;echo '&lt;td colspan=&quot;2&quot;&gt;LOCAL TV&lt;/td&gt;';</li><li>&nbsp;&nbsp;&nbsp;&nbsp;echo '&lt;td width=&quot;6&quot;&gt;&lt;/td&gt;';</li><li>&nbsp;&nbsp;&nbsp;&nbsp;echo '&lt;td&gt;NAT TV&lt;/td&gt;';</li><li>&nbsp;&nbsp;&nbsp;&nbsp;echo '&lt;td&gt;NOTES&lt;/td&gt;';</li><li>&nbsp;&nbsp;&nbsp;&nbsp;echo '&lt;/tr&gt;';</li><li>&nbsp;&nbsp;}</li><li>?&gt;</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Let&#8217;s gather info about the current game for display to the webpage, and for the hCalendar microformat.<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="php"><div class="devcodeoverflow"><ol><li> &lt;?php</li><li>&nbsp;&nbsp;// Check if we are processing an away game</li><li>&nbsp;&nbsp;$subject = $row['subject'];</li><li>&nbsp;&nbsp;$patt = &quot;/.*(@|vs.)(.*)/&quot;;</li><li>&nbsp;&nbsp;preg_match($patt, $subject, $opp);</li><li>&nbsp;&nbsp;$opponent = '';</li><li>&nbsp;</li><li>&nbsp;&nbsp;if ($opp[1] == &quot;@&quot;) {</li><li>&nbsp;&nbsp;&nbsp;&nbsp;$opponent = 'at ';</li><li>&nbsp;&nbsp;&nbsp;&nbsp;$eventInfo = 'Denver Nuggets ';</li><li>&nbsp;&nbsp;&nbsp;&nbsp;// Do not current have this info in the database</li><li>&nbsp;&nbsp;&nbsp;&nbsp;$eventLocation = ' ';</li><li>&nbsp;&nbsp;}</li><li>&nbsp;&nbsp;else {</li><li>&nbsp;&nbsp;&nbsp;&nbsp;$eventInfo = 'Denver Nuggets vs. ';</li><li>&nbsp;&nbsp;&nbsp;&nbsp;$eventLocation =</li><li>&nbsp;&nbsp;&nbsp;&nbsp; 'Pepsi Center loc: 1000 Chopper Cir Denver, CO 80204';</li><li>&nbsp;&nbsp;}</li><li>&nbsp;</li><li>&nbsp;&nbsp;// Append the opponent team name</li><li>&nbsp;&nbsp;$opponent .= $opp[2];</li><li>&nbsp;</li><li>&nbsp;&nbsp;// Check if the current game is broadcast in HD</li><li>&nbsp;&nbsp;if ($row['hdtv'])</li><li>&nbsp;&nbsp;&nbsp;&nbsp;$hdTVimage = '&lt;img src=&quot;/images/hdtv_logo_sm.jpg&quot; width=&quot;24&quot; height=&quot;18&quot; alt=&quot;HDTV&quot; /&gt;';</li><li>&nbsp;&nbsp;else</li><li>&nbsp;&nbsp;&nbsp;&nbsp;$hdTVimage = '';</li><li>?&gt;</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Now its time to create each remaining row in the schedule &#8211; and finally we get to create an hCalendar microformat. First, I&#8217;ll show you the code, without the hCalendar markup, for comparison.<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="php"><div class="devcodeoverflow"><ol><li>&lt;?php</li><li>&nbsp;&nbsp;// Game - no hCalendar microformat</li><li>&nbsp;&nbsp;echo '&lt;tr class=&quot;rowRegularSchedule&quot;&gt;';</li><li>&nbsp;&nbsp;echo '&lt;td&gt;' . $gameDate . '&lt;/td&gt;';</li><li>&nbsp;&nbsp;echo '&lt;td&gt;' . $eventInfo . $opponent . '&lt;/td&gt;';</li><li>&nbsp;&nbsp;echo '&lt;td&gt;' . $gameTime . '&lt;/td&gt;';</li><li>&nbsp;&nbsp;echo '&lt;td&gt;&lt;a href=&quot;http://www.altitude.tv&quot; target=&quot;_blank&quot;&gt;'. $row['lbroadcast'].'&lt;/a&gt;&lt;/td&gt;';</li><li>&nbsp;&nbsp;echo '&lt;td&gt;'.$hdTVimage.'&lt;/td&gt;';</li><li>&nbsp;&nbsp;echo '&lt;td width=&quot;5&quot;&gt;&lt;/td&gt;';</li><li>&nbsp;&nbsp;echo '&lt;td&gt;'. $row['broadcast'] . '&lt;/td&gt;';</li><li>&nbsp;&nbsp;echo '&lt;td&gt;' .$eventLocation . '&lt;/td&gt;';</li><li>&nbsp;&nbsp;echo '&lt;/tr&gt;';</li><li>} // End while</li><li>?&gt; </li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Pretty basic HTML, displaying our game information dynamically using PHP.</p>
<p>Finally, we&#8217;ll walk thru the microformat version. We start by creating a new row with the required class value of <em>vevent</em>. To give the event a name we use the <em>summary</em> class in a span element. Notice that I put a portion of the information within an abbr tag with the class of &#8220;mhide&#8221;. With CSS, I hide anything within an element using the mhide class from human eyes. I&#8217;ve recently read that the latest theory is to not hide any microformat information, because it looks like trickery to search engines like Google, and they may ding your page ranking for it. At this point, I&#8217;m not going to worry about that &#8211; I&#8217;d rather have a combination of usefulness and style &#8211; I want my microformat to provide event information without displaying more details than I need on the actual webpage. There may be a better way to handle this issue in the future, so I just wanted anyone following thru this example to be aware.<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="php"><div class="devcodeoverflow"><ol><li> &lt;?php</li><li>&nbsp;&nbsp;// microformat - hCalendar</li><li>&nbsp;&nbsp;echo '&lt;tr class=&quot;rowRegularSchedule vevent&quot;&gt;&lt;td&gt;' . $gameDate . '&lt;/td&gt;';</li><li>&nbsp;&nbsp;echo '&lt;td&gt;&lt;span class=&quot;summary&quot;&gt;&lt;abbr class=&quot;mhide&quot;&gt;' . $eventInfo . '&lt;/abbr&gt;' . $opponent . '&lt;/span&gt;&lt;/td&gt;';</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Now back to our partially defined microformat &#8211; so far we just have declared that we have an event and we&#8217;ve given it a title. Next, we&#8217;ll define the event&#8217;s start time and end time, which are the <em>dtstart</em> and <em>dtend </em>classes. We&#8217;ll display the start time and hide the end time since I don&#8217;t want to display that on the webpage. The abbr element has a useful title property where we will put the special date/time format that the microformat requires. (i.e. March 30th, 2007 at 8:00 MT is formatted as &#8220;2007-03-30T20:00-07:00&#8243;. The -07:00 provides the timezone information because it is the offset from Universal Time for the Mountain timezone)  Then the part we want to display simply goes within the abbr element itself.<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="php"><div class="devcodeoverflow"><ol><li></li><li>&nbsp;&nbsp;echo '&lt;td&gt;&lt;abbr class=&quot;dtstart&quot; title=&quot;' . $dtstartM .'&quot;&gt;' . $gameTime . '&lt;/abbr&gt;&lt;abbr class=&quot;mhide dtend&quot;';</li><li>&nbsp;&nbsp;echo 'title=&quot;' . $dendM . '&quot;&gt;' . $gameEnd . '&lt;/abbr&gt;&lt;/td&gt;';</li><li>&nbsp;&nbsp;echo '&lt;td&gt;&lt;a href=&quot;http://www.altitude.tv&quot; target=&quot;_blank&quot;&gt;'. $row['lbroadcast'].'&lt;/a&gt;&lt;/td&gt;&lt;td&gt;'.$hdTVimage.'&lt;/td&gt;';</li><li>&nbsp;&nbsp;echo '&lt;td width=&quot;5&quot;&gt;&lt;/td&gt;&lt;td&gt;'. $row['broadcast'].'&lt;/td&gt;';</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>The last property of the hCalendar microformat that I will make use of in this example is <em>location</em>. Then, once the tr element is closed, the hCalendar implementation is completed.<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="php"><div class="devcodeoverflow"><ol><li></li><li>&nbsp;&nbsp;echo '&lt;td&gt;&lt;span class=&quot;mhide location&quot;&gt;'.$eventLocation.'&lt;/span&gt;&lt;/td&gt;';</li><li>&nbsp;&nbsp;echo '&lt;/tr&gt;';</li><li>&nbsp;&nbsp;&nbsp;&nbsp;// End hCalendar Microformat</li><li>} // End while</li><li>?&gt;</li><li></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>There you have it. Embedded hCalendar events for each game, that are both human and machine readable, output as valid HTML.</p>
<p>If you found this useful and would like me to make the source code available for download, just leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ampedwebstandards.com/2007/03/29/creating-microformat-hcalendar-events-with-php/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
