<?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>Chris Kankiewicz &#187; Programming</title>
	<atom:link href="http://www.chriskankiewicz.com/posts/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chriskankiewicz.com</link>
	<description>Web Design &#8226; Graphic Design &#8226; Code</description>
	<lastBuildDate>Thu, 27 May 2010 21:26:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>First Friday script updated and simplified</title>
		<link>http://www.chriskankiewicz.com/posts/2009/02/14/first-friday-script-updated-and-simplified/</link>
		<comments>http://www.chriskankiewicz.com/posts/2009/02/14/first-friday-script-updated-and-simplified/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 02:40:04 +0000</pubDate>
		<dc:creator>Chris Kankiewicz</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[2600]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[First Friday]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Update]]></category>

		<guid isPermaLink="false">http://www.web-geek.net/?p=804</guid>
		<description><![CDATA[NOTE: The latest version of this script can always be found here: http://github.com/PHLAK/first-friday/blob/master/first-friday.php With this update I have drastically reduced and simpified the code to produce the same results.  I did some rigorous testing of my own to make sure &#8230; <a href="http://www.chriskankiewicz.com/posts/2009/02/14/first-friday-script-updated-and-simplified/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>NOTE: </strong>The latest version of this script can always be found here: <a href="http://github.com/PHLAK/first-friday/blob/master/first-friday.php">http://github.com/PHLAK/first-friday/blob/master/first-friday.php</a></p>
<p>With this update I have drastically reduced and simpified the code to produce the same results.  I did some rigorous testing of my own to make sure this script will calculate the correct date, but that doesn&#8217;t mean it&#8217;s bullet-proof.  If you find a bug, please email me so I can fix it.</p>
<p><strong>first-friday.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
  <span style="color: #666666; font-style: italic;">// Calculate next Friday</span>
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'d'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'d'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$timeStamp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mktime</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$x</span><span style="color: #339933;">,</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'w'</span><span style="color: #339933;">,</span><span style="color: #000088;">$timeStamp</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$nextFriday</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mktime</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$x</span><span style="color: #339933;">,</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #666666; font-style: italic;">// Check if next Friday is the first friday of the month.</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'d'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$nextFriday</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span> <span style="color: #cc66cc;">7</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$firstFriday</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$nextFriday</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// Calculate first Friday of next month</span>
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span> <span style="color: #cc66cc;">7</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$timeStamp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mktime</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #000088;">$x</span><span style="color: #339933;">,</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'w'</span><span style="color: #339933;">,</span><span style="color: #000088;">$timeStamp</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$firstFriday</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mktime</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #000088;">$x</span><span style="color: #339933;">,</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Echo next first Friday</span>
  <span style="color: #b1b100;">echo</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;F j, Y&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$firstFriday</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.chriskankiewicz.com/posts/2009/02/14/first-friday-script-updated-and-simplified/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Beginers Guide To Search Engine Optimization</title>
		<link>http://www.chriskankiewicz.com/posts/2008/11/20/beginers-guide-to-search-engine-optimization/</link>
		<comments>http://www.chriskankiewicz.com/posts/2008/11/20/beginers-guide-to-search-engine-optimization/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 18:06:02 +0000</pubDate>
		<dc:creator>Chris Kankiewicz</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Keywords]]></category>
		<category><![CDATA[robots.txt]]></category>
		<category><![CDATA[Search Engine Optimization]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Sitemaps]]></category>
		<category><![CDATA[Yahoo!]]></category>

		<guid isPermaLink="false">http://www.web-geek.net/?p=719</guid>
		<description><![CDATA[The following is a quick list of optimizations that, in my years of web development, I have observed will help increase your sites search engine ranking.  While none of these processes are guaranteed to make your site #1 in Google &#8230; <a href="http://www.chriskankiewicz.com/posts/2008/11/20/beginers-guide-to-search-engine-optimization/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The following is a quick list of optimizations that, in my years of web development, I have observed will help increase your sites search engine ranking.  While none of these processes are guaranteed to make your site #1 in Google overnight, I can promise that by implementing all (or even some) of these items, in time your site&#8217;s rank will rise.</p>
<p>The following items are clean, honest ways to optimize your site.  I do not condone, nor solicit, any form of &#8220;black hat&#8221; search engine optimization and frown upon it greatly.  If that&#8217;s what you&#8217;re aiming to implement, I sincerely hope that Google blacklists your site tomorrow.  Please don&#8217;t send me any emails asking how to get your sight listed as #1 tomorrow.</p>
<p>Now, onto the list.</p>
<p><span id="more-719"></span></p>
<h2>Code to Standards</h2>
<p>Whether or not you&#8217;re aiming for SEO, keeping your code standards compliant will make your site better all around and help make post-development changes much simpler.  While the effectiveness of coding to standards is still debated in the SEO community, it&#8217;s generally believed that a standards compliant page will rank slightly higher than a non-compliant page with the same content.</p>
<p>Also, by adhering to standards, you&#8217;ll have a much easier time implementing the rest of the processes on this list.</p>
<h2>Content is King</h2>
<p>The first and foremost rule you&#8217;ll hear from many SEO &#8220;experts&#8221; mouth will most likely be &#8220;content is king.&#8221;  Of all the processes detailed on this page, if your site doesn&#8217;t contain valuable content to the end user, your page rank will likely not be very high.</p>
<p>To take this concept one step further, I&#8217;m going to add to that saying to create my own spin off.  As opposed to just &#8220;content&#8221;, my saying specifies that &#8220;<strong>dynamic</strong> content is king.&#8221;  While a site with any content at all is far superior to one without, I believe that adding something as simple as a twitter feed to your home page will help convince the search engines that your site is more important.  After all, users (and therefore, probably search engines) love new content.  To expand upon this idea, if it would fit your site, try adding a blog or a forum to keep that content fresh.</p>
<h2>Separate Content and Style</h2>
<p>When a search engine crawls your site, it doesn&#8217;t see the same thing your end use sees.  The search engine sees the underlying code that is output by your site.  For an example of what the search engine sees, right click your web page and choose &#8220;View Source.&#8221;  This is a much more accurate (though not exact) representation of what the search engine sees.</p>
<p>If you clutter your code with multitudes of nested tables and lots of in-line styling properties the search engine may have a hard time finding your content to index.  Instead of nesting table after table, consider using divs.  If you don&#8217;t know how to use divs, I strongly suggest you learn.  Also, instead of adding the &#8220;style&#8221; property in line with your (X)HTML, create a separate file named style.css and add the following code between your pages head tags to call this file upon page load:</p>
<pre id="line1"><span style="color: #333399;">&lt;link rel="stylesheet" href="style.css" type="text/css" /&gt;</span></pre>
<p>All you have to do now is add your CSS elements to this style.css file, and give your (X)HTML element either a class or id.  For more on classes and ids, see <a title="CSS Syntax | W3Schools" href="http://www.w3schools.com/Css/css_syntax.asp" target="_blank">http://www.w3schools.com/Css/css_syntax.asp</a>.</p>
<h2>Use Human Readable URL&#8217;s</h2>
<p>The ability for a user to accurately guess what a page will contain by looking at a link will not only help your users find what they&#8217;re looking for, but is also a good SEO technique.  See below for an example of human readable URL&#8217;s.</p>
<p>Good Examples:</p>
<ul>
<li>www.domain.com/dog-food</li>
<li>www.domain.com/dog/food</li>
</ul>
<p>Poor Examples:</p>
<ul>
<li>www.domain.com/1337</li>
<li>www.domain.com/index.php?page=1337</li>
</ul>
<h2>Page Title Format</h2>
<p>While it may not seem too important, the title of your page can make a difference to your page ranking.  While a title in the format of &#8220;Site Name | Page Title&#8221; is in no way bad, it&#8217;s generally believed that the best format for a tile is &#8220;Page Title | Site Name.&#8221;  Also, there are many pages out there that list every directory in their title, this is not necessary and clutters the title so readers have a tougher time identifying the page.</p>
<p>Good examples:</p>
<ul>
<li>SEO Guide | Web Geek</li>
<li>CK-Gallery • Web Geek</li>
<li>Menu &#8211; Taco Bell</li>
</ul>
<p>Poor examples:</p>
<ul>
<li>Web Geek | SEO Guide</li>
<li>Web Geek &gt; Web Development &gt; SEO Guide</li>
<li>www.web-geek.net | projects | php | ck-gallery</li>
</ul>
<h2>Header Tag Prioritization</h2>
<p>The importance of a title should directly affect which header tag that title gets (ie &lt;h1&gt;. &lt;h2&gt;, &lt;h3&gt;, etc&#8230;).  The more important a title is, the closer to &lt;h1&gt; the title should be with &lt;h1&gt; being the page title and something like a paragraph heading being an &lt;h2&gt; or &lt;h3&gt; depending on it&#8217;s importance.  If one topic is just as important as another, they should have the same title tag.</p>
<h2>Create a Sitemap</h2>
<p>Every website with more than a single page should have a sitemap.  You can make a sitemap in many ways and in many formats, though the most widely accepted by most search engines is an XML sitemap.</p>
<p>My favorite site for sitemap generation is <a title="Creat your own Google Sitemap Online" href="http://www.xml-sitemaps.com/" target="_blank">http://www.xml-sitemaps.com/</a>.  This site will automatically crawl up to 500 pages and generate XML, GZipped, and HTML sitemaps that you can then upload to your own site.  Once you have uploaded your sitemap, head on over to <a title="Google Webmaster Tools" href="https://www.google.com/webmasters/tools" target="_blank">https://www.google.com/webmasters/tools</a> and add your sitemap for Google to index.</p>
<p>Note: Even though you can put a sitemap anywhere, the most common location for a sitemap is in your sites root directory (<a title="Web Geek Sitemap" href="http://www.web-geek.net/sitemap.xml" target="_blank">http://www.web-geek.net/sitemap.xml</a>)</p>
<h2>Use Relevant Keywords</h2>
<p>Keywords are a difficult area in SEO.  You need to specify keywords relevant to your site but you don&#8217;t want to have too many keywords or you&#8217;ll be hurting your site more than helping.  The generally accepted maximum number of keywords to include on your page is usually 10, for most sites, and definitely no more than 20 for larger sites.  Though major search engines don&#8217;t take the number of keywords on your page into consideration when assigning you a page rank, by having to many keywords, it&#8217;s harder for a search engine to identify which ones are more relevant than others.</p>
<p>To include keywords on your page, place the following code between your head tags.</p>
<pre><span style="color: #333399;">&lt;<span class="start-tag">meta</span><span class="attribute-name"> name</span>=<span class="attribute-value">"keywords" </span><span class="attribute-name">content</span>=<span class="attribute-value">"keyword 1, keyword 2, keyword 3" </span><span class="error"><span class="attribute-name">/</span></span>&gt;</span></pre>
<p>Also, you generally don&#8217;t want the exact same keywords on any pages unless they&#8217;re content matches.  Give each page keywords that are relevant to the content on that page.  You also may wish to consider generating your keywords dynamically.</p>
<h2>Use the &#8220;title&#8221; Attribute for Links</h2>
<p>When creating a link, be sure to include a relevant description of the link using the title attribute.  This adds content for a search engine to pick up and also, when a user hovers over that link, they will get a popup showing your description.</p>
<p>Example:</p>
<pre><span style="color: #333399;">&lt;a href="http://www.web-geek.net/ck-gallery" title="Dynamic PHP Photo Gallery"&gt;CK-Gallery&lt;/a&gt;
</span></pre>
<p>The above code will create the following link (hover over it to see the title): <a title="Dynamic PHP Photo Gallery" href="http://www.web-geek.net/ck-gallery">CK-Gallery</a></p>
<h2>Submit your site for indexing</h2>
<p>One of the best ways to get your site noticed by a search engine is to manually submit it for indexing to major search engines.  This is especially useful when your site isn&#8217;t yet listed in a search engine.</p>
<p>Google: <a title="Add your URL to Google" href="http://www.google.com/addurl/" target="_blank">http://www.google.com/addurl/</a></p>
<p>Yahoo: <a title="Yahoo! Site Submit" href="http://siteexplorer.search.yahoo.com/submit" target="_blank">http://siteexplorer.search.yahoo.com/submit</a></p>
<h2>Create a robots.txt file</h2>
<p>A robots.txt file can be used to limit what directories/files a web robot can access.  This helps prevent a robot from accessing data you do not wish to be cached by search engines and instead cache only the pages you want to appear.  A good resource on creating and using a robots.txt file can be found at <a title="About /robots.txt" href="http://www.robotstxt.org/robotstxt.html" target="_blank">http://www.robotstxt.org/robotstxt.html</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chriskankiewicz.com/posts/2008/11/20/beginers-guide-to-search-engine-optimization/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Calculate the first Friday of next month with PHP</title>
		<link>http://www.chriskankiewicz.com/posts/2008/10/20/calculate-the-first-friday-of-next-month-with-php/</link>
		<comments>http://www.chriskankiewicz.com/posts/2008/10/20/calculate-the-first-friday-of-next-month-with-php/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 05:50:40 +0000</pubDate>
		<dc:creator>Chris Kankiewicz</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[First Friday]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHX2600]]></category>

		<guid isPermaLink="false">http://www.web-geek.net/?p=597</guid>
		<description><![CDATA[UPDATE: This script has been updated, see: http://www.web-geek.net/posts/2009/02/14/first-friday-script-updated-and-simplified/ While developing phx2600.org, I ran into a slight dilemma.  The PHX2600 meetings occur once a month on the first Friday of every month, and we wanted to display that on the site.  &#8230; <a href="http://www.chriskankiewicz.com/posts/2008/10/20/calculate-the-first-friday-of-next-month-with-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE:</strong> This script has been updated, see: <a href="http://www.web-geek.net/posts/2009/02/14/first-friday-script-updated-and-simplified/">http://www.web-geek.net/posts/2009/02/14/first-friday-script-updated-and-simplified/</a></p>
<p>While developing <a title="PHX2600 - Phoenix, Arizona Netowrk of Hackers" href="http://www.phx2600.org" target="_blank">phx2600.org</a>, I ran into a slight dilemma.  The PHX2600 meetings occur once a month on the first Friday of every month, and we wanted to display that on the site.  However, it was becoming a tedious chore to change the date once a month manually.  So, being the automation addict I am, I thought, why not write a script.  So one night I hammered out the following script that will calculate the first Friday of next month:</p>
<p><span id="more-597"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">/***************************************
  *  FILENAME: first-friday.php          *
  *  AUTHOR:   Chris Kankiewicz [PHLAK]  *
  *  WEBSITE:  http://www.web-geek.net   *
  ***************************************/</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// START FUNCTIONS</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> get_day<span style="color: #009900;">&#40;</span><span style="color: #000088;">$describer</span><span style="color: #339933;">,</span><span style="color: #000088;">$weekday</span><span style="color: #339933;">,</span><span style="color: #000088;">$reference_date</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// $reference_date format = m-Y</span>
&nbsp;
    <span style="color: #000088;">$d</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'-'</span><span style="color: #339933;">,</span><span style="color: #000088;">$reference_date</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$describer</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'first'</span><span style="color: #339933;">:</span> <span style="color: #000088;">$offset</span> <span style="color: #339933;">=</span> get_day_offset<span style="color: #009900;">&#40;</span><span style="color: #000088;">$reference_date</span><span style="color: #339933;">,</span><span style="color: #000088;">$weekday</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$r</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mktime</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #000088;">$d</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">+</span><span style="color: #000088;">$offset</span><span style="color: #339933;">,</span><span style="color: #000088;">$d</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$r</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">//returns timestamp format</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> get_day_offset<span style="color: #009900;">&#40;</span><span style="color: #000088;">$anchor</span><span style="color: #339933;">,</span><span style="color: #000088;">$target</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//$anchor format = m-Y</span>
&nbsp;
    <span style="color: #000088;">$ts</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'-'</span><span style="color: #339933;">,</span><span style="color: #000088;">$anchor</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$ts</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mktime</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #000088;">$ts</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'01'</span><span style="color: #339933;">,</span><span style="color: #000088;">$ts</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$anchor</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;w&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$ts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$target</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$target</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$days</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
      <span style="color: #0000ff;">'sunday'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'monday'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'tuesday'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'wednesday'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'thursday'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'friday'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'saturday'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">6</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$offset</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$days</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$target</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$anchor</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$offset</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$offset</span><span style="color: #339933;">+=</span><span style="color: #cc66cc;">7</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$offset</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">//returns 0-6 for use in get_day();</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//END FUNCTIONS</span>
&nbsp;
  <span style="color: #000088;">$t</span> <span style="color: #339933;">=</span> <span style="color: #990000;">getdate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Get today's date</span>
&nbsp;
  <span style="color: #000088;">$today</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m-Y'</span><span style="color: #339933;">,</span><span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Display today's date as MM-YYYY</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//Calculate Next Month</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span>mon<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'12'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$nm</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'1-'</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span>year<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span>mday<span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;=</span> <span style="color: #0000ff;">'7'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span>wday<span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;=</span> <span style="color: #0000ff;">'5'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$nm</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span>mon<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'-'</span><span style="color: #339933;">.</span><span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span>year<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>	<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$nm</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span>mon<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'-'</span><span style="color: #339933;">.</span><span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span>year<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> get_day<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;first&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;friday&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$nm</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//Checks if today is after the first friday of the month</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span>mon<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m'</span><span style="color: #339933;">,</span><span style="color: #000088;">$date</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span>mday<span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'j'</span><span style="color: #339933;">,</span><span style="color: #000088;">$date</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span>mon<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'12'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$nm</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'1-'</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span>year<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$ff</span> <span style="color: #339933;">=</span> get_day<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;first&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;friday&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$nm</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span>mon<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m'</span><span style="color: #339933;">,</span><span style="color: #000088;">$date</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span>mday<span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'j'</span><span style="color: #339933;">,</span><span style="color: #000088;">$date</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span>mon<span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'12'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$nm</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span>mon<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'-'</span><span style="color: #339933;">.</span><span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span>year<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$ff</span> <span style="color: #339933;">=</span> get_day<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;first&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;friday&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$nm</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>	<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$ff</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$date</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// I know this code is crap, deal with it or fix it yourself!</span>
&nbsp;
  <span style="color: #b1b100;">echo</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;F j, Y&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ff</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>I apologies for the crappy code, I was either tired, drunk or both the night I wrote this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chriskankiewicz.com/posts/2008/10/20/calculate-the-first-friday-of-next-month-with-php/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Creating Dynamic Menus with PHP and CSS</title>
		<link>http://www.chriskankiewicz.com/posts/2008/10/05/creating-dynamic-menus-with-php-and-css/</link>
		<comments>http://www.chriskankiewicz.com/posts/2008/10/05/creating-dynamic-menus-with-php-and-css/#comments</comments>
		<pubDate>Mon, 06 Oct 2008 00:25:34 +0000</pubDate>
		<dc:creator>Chris Kankiewicz</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Dynamic Menus]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.web-geek.net/?p=420</guid>
		<description><![CDATA[Want to pep up your web page with some dynamic menus? Here&#8217;s a simple solution that only requires a few lines of PHP and CSS. UPDATE (11/1/08): Simplified the header code and edited the syntax of the list element echo &#8230; <a href="http://www.chriskankiewicz.com/posts/2008/10/05/creating-dynamic-menus-with-php-and-css/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Want to pep up your web page with some dynamic menus?  Here&#8217;s a simple solution that only requires a few lines of PHP and CSS.</p>
<p><strong>UPDATE (11/1/08):</strong> Simplified the header code and edited the syntax of the list element echo code.</p>
<h3>The PHP</h3>
<p>Add the following to the top of your page (before the DOCTYPE or HTML tag).</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
  <span style="color: #666666; font-style: italic;">// Get current page file name</span>
  <span style="color: #000088;">$page</span> <span style="color: #339933;">=</span> <span style="color: #990000;">basename</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;PHP_SELF&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Then add the following to your menu item where you want the class designation to show up.</p>
<p><span id="more-420"></span></p>
<p>Each link should have this piece of code in it.  Make sure you replace &#8220;index.php&#8221; with the appropriate file name for the page.  Example:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;div id=&quot;navigation&quot;&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;a href=&quot;index.php&quot; <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;index.php&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">' class=&quot;current&quot;'</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;Home&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;resume.php&quot;&gt;&amp;gt;Resume&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;photography.php&quot;&gt;&amp;gt;Photography&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;about.php&quot;&gt;&amp;gt;About&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;contact.php&quot;&gt;&amp;gt;Contact&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;</pre></div></div>

<p><em>Note: the 2 chevrons &#8220;>>&#8221; at the end are on purpose.  One closes the PHP tag the other closes the &#8216;a&#8217; tag.</em></p>
<h3>The CSS</h3>
<p>Lastly, add the following element to your style sheet and style it as you please.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#navigation</span> ul li a<span style="color: #6666ff;">.current</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#FFF</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#FFF</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>This process will result in the following:</p>
<p><img class="aligncenter size-full wp-image-437 border" title="Chris Kankiewicz Dynamic Menu Tabs" src="http://chriskankiewicz.com/wp-content/uploads/2008/10/ck-menu-tabs.png" alt="" width="700" height="121" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.chriskankiewicz.com/posts/2008/10/05/creating-dynamic-menus-with-php-and-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
