<?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>jtGraphic: James Thompson &#187; Programming</title>
	<atom:link href="http://www.jtgraphic.net/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jtgraphic.net</link>
	<description>I can help you get where you want to go on the Internet.  We&#039;ll have fun along the way too.</description>
	<lastBuildDate>Mon, 26 Jul 2010 12:00:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Automated Way to Find Google Pagerank</title>
		<link>http://www.jtgraphic.net/2010/06/automated-find-google-pagerank/</link>
		<comments>http://www.jtgraphic.net/2010/06/automated-find-google-pagerank/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 21:11:41 +0000</pubDate>
		<dc:creator>James Thompson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Pagerank]]></category>
		<category><![CDATA[Program]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[Tidbit Tuesday]]></category>

		<guid isPermaLink="false">http://www.jtgraphic.net/?p=722</guid>
		<description><![CDATA[
			
				
			
		
<p>I was looking for an automated way to get Google Pagerank for a few hours and came up with quite a few things, but not many of them were very elegant.  Essentially, Google doesn&#8217;t provide an API and it&#8217;s against their terms of service to hit them up in an automated way.  I found quite a <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.jtgraphic.net/2010/06/automated-find-google-pagerank/">Automated Way to Find Google Pagerank</a></span><p><a href="http://www.jtgraphic.net/2010/06/automated-find-google-pagerank/">Automated Way to Find Google Pagerank</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>
]]></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.jtgraphic.net%2F2010%2F06%2Fautomated-find-google-pagerank%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F06%2Fautomated-find-google-pagerank%2F&amp;source=jtgraphic&amp;style=normal&amp;service=bit.ly&amp;hashtags=Google,Pagerank,Program,Programming,seo,Tidbit+Tuesday" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.jtgraphic.net/wp-content/google-pagerank.png"><img class="alignright size-medium wp-image-729" title="google-pagerank" src="http://www.jtgraphic.net/wp-content/google-pagerank-300x133.png" alt="" width="300" height="133" /></a>I was looking for an automated way to get Google Pagerank for a few hours and came up with quite a few things, but not many of them were very elegant.  Essentially, Google doesn&#8217;t provide an API and it&#8217;s against their terms of service to hit them up in an automated way.  I found quite a few places that have come up with close algorithms and calculate PR for sites, but that&#8217;s just not accurate enough for me.  The other option is to hit their PR URL that the toolbar uses.  For example:</p>
<p><a href="http://toolbarqueries.google.com/search?client=navclient-auto&amp;hl=en&amp;ch=61470319184&amp;ie=UTF-8&amp;oe=UTF-8&amp;features=Rank&amp;q=info:http%3A%2F%2Fforums.digitalpoint.com%2Fshowthread.php%3Ft%3D164713" target="_blank">http://toolbarqueries.google.com/search?client=navclient-auto&amp;hl=en&amp;ch=61470319184&amp;ie=UTF-8&amp;oe=UTF-8&amp;features=Rank&amp;q=info:http%3A%2F%2Fforums.digitalpoint.com%2Fshowthread.php%3Ft%3D164713</a></p>
<p>That returns the PR of Digital Point Forums, where I found that information, but you can&#8217;t change the reference URL, because of a checksum.  That&#8217;s the &amp;ch= variable in the URL.  I&#8217;m working on a project that needs to look up PR on the fly though, so that just won&#8217;t work.  I ended up finding a script that I could use, but the guy didn&#8217;t put his URL in the comments, and I since can&#8217;t find it &#8211; oops.  I think he deserves a pat on the back though.  If this belongs to you, or you know who&#8217;s it is, let me know.</p>
<p>I tweaked the script and installed it on my <a href="http://toolerific.com" target="_blank">Toolerific.com</a> website.  Now you can go there and check the PR of any site without a captcha, which is nice.  The tool is <a href="http://toolerific.com/pagerankcheck/" target="_blank">here</a>.</p>
<p>Now, the best automated way to check pagerank is to hit that site with cURL and take out the value of the HTML tag with the id &#8220;value&#8221;.  The reason that is the best automated way to do it is because Google may change their checksum rules and that will break the source code that I used to generate it, but that site will always be laid out like that, so you don&#8217;t have to worry about changing anything.  If you want the code I used, you can view it <a href="http://www.jtgraphic.net/code/june-2010-pr-checker-php-script/">here</a>.</p>
<p><em><strong>Update</strong>: This doesn&#8217;t seem to work ALL of the time.  I suspect it has something to do with the checksum, but can&#8217;t figure it out.  Seems to be about 27% of the time, which isn&#8217;t great odds, but it works MOST of the time.  I&#8217;ll keep you posted if I find out more.</em></p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li style="clear: both;"><a href="http://www.jtgraphic.net/code/june-2010-pr-checker-php-script/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="June 2010 PR Checker PHP Script" title="June 2010 PR Checker PHP Script" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/code/june-2010-pr-checker-php-script/" rel="bookmark" class="crp_title">June 2010 PR Checker PHP Script</a><span class="crp_excerpt"> &lt;?php
function StrToNum($Str, $Check, $Magic)
{
 $Int32Unit = 4294967296;  // 2^32
 
 $length = strlen($Str);
 for ($i = 0; $i &lt; $length; ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2010/06/pros-cons-url-shortening-services/" rel="bookmark"><img width="50" height="40" src="http://www.jtgraphic.net/wp-content/google-goo-gl-url-shortening-service-300x242.jpg" class="crp_thumb wp-post-image" alt="Pros and Cons of URL Shortening Services" title="Pros and Cons of URL Shortening Services" border="0" /></a> <a href="http://www.jtgraphic.net/2010/06/pros-cons-url-shortening-services/" rel="bookmark" class="crp_title">Pros and Cons of URL Shortening Services</a><span class="crp_excerpt"> URL Shortening services have become all the rage recently, especially with the character limitations on twitter.  They have their advantages, ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2008/12/google-image-search-upgraded/" rel="bookmark"><img width="50" height="50" src="http://www.jtgraphic.net/wp-content/google-150x150.jpg" class="crp_thumb wp-post-image" alt="Google Image Search Gets Upgraded" title="Google Image Search Gets Upgraded" border="0" /></a> <a href="http://www.jtgraphic.net/2008/12/google-image-search-upgraded/" rel="bookmark" class="crp_title">Google Image Search Gets Upgraded</a><span class="crp_excerpt"> Google image search has always been a great tool for finding images of things, but it has never been great ...</span></li></ul></div><p><a href="http://www.jtgraphic.net/2010/06/automated-find-google-pagerank/">Automated Way to Find Google Pagerank</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F06%2Fautomated-find-google-pagerank%2F&amp;title=Automated%20Way%20to%20Find%20Google%20Pagerank&amp;bodytext=I%20was%20looking%20for%20an%20automated%20way%20to%20get%20Google%20Pagerank%20for%20a%20few%20hours%20and%20came%20up%20with%20quite%20a%20few%20things%2C%20but%20not%20many%20of%20them%20were%20very%20elegant.%C2%A0%20Essentially%2C%20Google%20doesn%27t%20provide%20an%20API%20and%20it%27s%20against%20their%20terms%20of%20service%20to%20hit%20them%20up" title="Digg"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F06%2Fautomated-find-google-pagerank%2F&amp;title=Automated%20Way%20to%20Find%20Google%20Pagerank&amp;notes=I%20was%20looking%20for%20an%20automated%20way%20to%20get%20Google%20Pagerank%20for%20a%20few%20hours%20and%20came%20up%20with%20quite%20a%20few%20things%2C%20but%20not%20many%20of%20them%20were%20very%20elegant.%C2%A0%20Essentially%2C%20Google%20doesn%27t%20provide%20an%20API%20and%20it%27s%20against%20their%20terms%20of%20service%20to%20hit%20them%20up" title="del.icio.us"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=facebook-post&t=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F06%2Fautomated-find-google-pagerank%2F&d=http://www.facebook.com/share.php?u=TARGET%26t=Automated%20Way%20to%20Find%20Google%20Pagerank" title="Facebook"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F06%2Fautomated-find-google-pagerank%2F&amp;title=Automated%20Way%20to%20Find%20Google%20Pagerank" title="Mixx"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F06%2Fautomated-find-google-pagerank%2F&amp;title=Automated%20Way%20to%20Find%20Google%20Pagerank&amp;annotation=I%20was%20looking%20for%20an%20automated%20way%20to%20get%20Google%20Pagerank%20for%20a%20few%20hours%20and%20came%20up%20with%20quite%20a%20few%20things%2C%20but%20not%20many%20of%20them%20were%20very%20elegant.%C2%A0%20Essentially%2C%20Google%20doesn%27t%20provide%20an%20API%20and%20it%27s%20against%20their%20terms%20of%20service%20to%20hit%20them%20up" title="Google Bookmarks"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F06%2Fautomated-find-google-pagerank%2F&amp;title=Automated%20Way%20to%20Find%20Google%20Pagerank" title="StumbleUpon"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F06%2Fautomated-find-google-pagerank%2F" title="Technorati"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=myspace&t=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F06%2Fautomated-find-google-pagerank%2F&d=http://www.myspace.com/Modules/PostTo/Pages/?u=TARGET%26t=Automated%20Way%20to%20Find%20Google%20Pagerank" title="MySpace"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=twitter&t=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F06%2Fautomated-find-google-pagerank%2F&d=http://twitter.com/home?status=Automated%20Way%20to%20Find%20Google%20Pagerank%20-%20TARGET" title="Twitter"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F06%2Fautomated-find-google-pagerank%2F" title="Sphinn"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F06%2Fautomated-find-google-pagerank%2F&amp;title=Automated%20Way%20to%20Find%20Google%20Pagerank" title="Reddit"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.jtgraphic.net/2010/06/automated-find-google-pagerank/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tidbit Tuesday: Paginating in MSSQL</title>
		<link>http://www.jtgraphic.net/2010/03/tidbit-tuesday-paginating-mssql/</link>
		<comments>http://www.jtgraphic.net/2010/03/tidbit-tuesday-paginating-mssql/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 04:25:41 +0000</pubDate>
		<dc:creator>James Thompson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[limit]]></category>
		<category><![CDATA[mssql]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[Tidbit Tuesday]]></category>

		<guid isPermaLink="false">http://www.jtgraphic.net/?p=547</guid>
		<description><![CDATA[
			
				
			
		
<p>I don&#8217;t really work with MSSQL very much and was wondering how to do pagination similar to doing it in MySQL with the LIMIT command.  It&#8217;s MUCH harder in MSSQL, but here is how you do it:</p>
SELECT * FROM
 (SELECT TOP [size_of_record_set] * FROM
 (SELECT TOP [end_record] * FROM [table] ORDER BY [field] ASC) AS tbl1 <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.jtgraphic.net/2010/03/tidbit-tuesday-paginating-mssql/">Tidbit Tuesday: Paginating in MSSQL</a></span><p><a href="http://www.jtgraphic.net/2010/03/tidbit-tuesday-paginating-mssql/">Tidbit Tuesday: Paginating in MSSQL</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>
]]></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.jtgraphic.net%2F2010%2F03%2Ftidbit-tuesday-paginating-mssql%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Ftidbit-tuesday-paginating-mssql%2F&amp;source=jtgraphic&amp;style=normal&amp;service=bit.ly&amp;hashtags=limit,mssql,MySQL,pagination,Tidbit+Tuesday" height="61" width="50" /><br />
			</a>
		</div>
<p>I don&#8217;t really work with MSSQL very much and was wondering how to do pagination similar to doing it in MySQL with the LIMIT command.  It&#8217;s MUCH harder in MSSQL, but here is how you do it:</p>
<pre class="brush: php">SELECT * FROM
 (SELECT TOP [size_of_record_set] * FROM
 (SELECT TOP [end_record] * FROM [table] ORDER BY [field] ASC) AS tbl1 ORDER BY [field] DESC
 ) AS tbl2</pre>
<div id="crp_related"><h3>Related Posts:</h3><ul><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-query-function/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="Tidbit Tuesday on PHP: Simple MySQL Database Query Function" title="Tidbit Tuesday on PHP: Simple MySQL Database Query Function" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-query-function/" rel="bookmark" class="crp_title">Tidbit Tuesday on PHP: Simple MySQL Database Query Function</a><span class="crp_excerpt"> It's always great to create functions for those things you do a lot.  Probably the single most common function I ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-insert-function/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="Tidbit Tuesday on PHP: Simple MySQL Database Insert Function" title="Tidbit Tuesday on PHP: Simple MySQL Database Insert Function" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-insert-function/" rel="bookmark" class="crp_title">Tidbit Tuesday on PHP: Simple MySQL Database Insert Function</a><span class="crp_excerpt"> This builds on a function I did last week: db_query().  You can send any array straight to a MySQL ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/10/php-function-friday-date/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="PHP Function Friday: date" title="PHP Function Friday: date" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/10/php-function-friday-date/" rel="bookmark" class="crp_title">PHP Function Friday: date</a><span class="crp_excerpt"> I think the date function is extremely useful.  It gives your programs an awareness of WHEN they are.  You can ...</span></li></ul></div><p><a href="http://www.jtgraphic.net/2010/03/tidbit-tuesday-paginating-mssql/">Tidbit Tuesday: Paginating in MSSQL</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Ftidbit-tuesday-paginating-mssql%2F&amp;title=Tidbit%20Tuesday%3A%20Paginating%20in%20MSSQL&amp;bodytext=I%20don%27t%20really%20work%20with%20MSSQL%20very%20much%20and%20was%20wondering%20how%20to%20do%20pagination%20similar%20to%20doing%20it%20in%20MySQL%20with%20the%20LIMIT%20command.%C2%A0%20It%27s%20MUCH%20harder%20in%20MSSQL%2C%20but%20here%20is%20how%20you%20do%20it%3A%0D%0ASELECT%20%2A%20FROM%0D%0A%20%28SELECT%20TOP%20%5Bsize_of_record_set%5D%20%2A%20FROM%0D%0A%20%28S" title="Digg"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Ftidbit-tuesday-paginating-mssql%2F&amp;title=Tidbit%20Tuesday%3A%20Paginating%20in%20MSSQL&amp;notes=I%20don%27t%20really%20work%20with%20MSSQL%20very%20much%20and%20was%20wondering%20how%20to%20do%20pagination%20similar%20to%20doing%20it%20in%20MySQL%20with%20the%20LIMIT%20command.%C2%A0%20It%27s%20MUCH%20harder%20in%20MSSQL%2C%20but%20here%20is%20how%20you%20do%20it%3A%0D%0ASELECT%20%2A%20FROM%0D%0A%20%28SELECT%20TOP%20%5Bsize_of_record_set%5D%20%2A%20FROM%0D%0A%20%28S" title="del.icio.us"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=facebook-post&t=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Ftidbit-tuesday-paginating-mssql%2F&d=http://www.facebook.com/share.php?u=TARGET%26t=Tidbit%20Tuesday%3A%20Paginating%20in%20MSSQL" title="Facebook"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Ftidbit-tuesday-paginating-mssql%2F&amp;title=Tidbit%20Tuesday%3A%20Paginating%20in%20MSSQL" title="Mixx"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Ftidbit-tuesday-paginating-mssql%2F&amp;title=Tidbit%20Tuesday%3A%20Paginating%20in%20MSSQL&amp;annotation=I%20don%27t%20really%20work%20with%20MSSQL%20very%20much%20and%20was%20wondering%20how%20to%20do%20pagination%20similar%20to%20doing%20it%20in%20MySQL%20with%20the%20LIMIT%20command.%C2%A0%20It%27s%20MUCH%20harder%20in%20MSSQL%2C%20but%20here%20is%20how%20you%20do%20it%3A%0D%0ASELECT%20%2A%20FROM%0D%0A%20%28SELECT%20TOP%20%5Bsize_of_record_set%5D%20%2A%20FROM%0D%0A%20%28S" title="Google Bookmarks"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Ftidbit-tuesday-paginating-mssql%2F&amp;title=Tidbit%20Tuesday%3A%20Paginating%20in%20MSSQL" title="StumbleUpon"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Ftidbit-tuesday-paginating-mssql%2F" title="Technorati"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=myspace&t=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Ftidbit-tuesday-paginating-mssql%2F&d=http://www.myspace.com/Modules/PostTo/Pages/?u=TARGET%26t=Tidbit%20Tuesday%3A%20Paginating%20in%20MSSQL" title="MySpace"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=twitter&t=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Ftidbit-tuesday-paginating-mssql%2F&d=http://twitter.com/home?status=Tidbit%20Tuesday%3A%20Paginating%20in%20MSSQL%20-%20TARGET" title="Twitter"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Ftidbit-tuesday-paginating-mssql%2F" title="Sphinn"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Ftidbit-tuesday-paginating-mssql%2F&amp;title=Tidbit%20Tuesday%3A%20Paginating%20in%20MSSQL" title="Reddit"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.jtgraphic.net/2010/03/tidbit-tuesday-paginating-mssql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Twitter API</title>
		<link>http://www.jtgraphic.net/2010/02/twitter-api/</link>
		<comments>http://www.jtgraphic.net/2010/02/twitter-api/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 06:15:06 +0000</pubDate>
		<dc:creator>James Thompson</dc:creator>
				<category><![CDATA[Insights]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[curl_close]]></category>
		<category><![CDATA[curl_exec]]></category>
		<category><![CDATA[curl_init]]></category>
		<category><![CDATA[curl_setopt]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tidbit Tuesday]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.jtgraphic.net/?p=493</guid>
		<description><![CDATA[
			
				
			
		
<p>I&#8217;ve been messing with the Twitter API for the first time in the last few hours, and I&#8217;ve learned a TON.  I know &#8211; I&#8217;m jumping on the bandwagon late, but oh well.  I managed to create a script to retweet &#8220;stuff&#8221; based on the search functionality and I made a script to automatically follow people <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.jtgraphic.net/2010/02/twitter-api/">The Twitter API</a></span><p><a href="http://www.jtgraphic.net/2010/02/twitter-api/">The Twitter API</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>
]]></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.jtgraphic.net%2F2010%2F02%2Ftwitter-api%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F02%2Ftwitter-api%2F&amp;source=jtgraphic&amp;style=normal&amp;service=bit.ly&amp;hashtags=API,curl_close,curl_exec,curl_init,curl_setopt,PHP,Tidbit+Tuesday,Twitter" height="61" width="50" /><br />
			</a>
		</div>
<p>I&#8217;ve been messing with the Twitter API for the first time in the last few hours, and I&#8217;ve learned a TON.  I know &#8211; I&#8217;m jumping on the bandwagon late, but oh well.  I managed to create a script to retweet &#8220;stuff&#8221; based on the search functionality and I made a script to automatically follow people that post specific things.  I also managed to get my account suspended in like 2 hours due to suspicious activity &#8211; whoops.  I guess you live, you learn.  Basically everything for status updates and following uses CURL, which looks a little something like this:</p>
<pre class="brush: php">&lt;?php
 $username = "&lt;username&gt;";
 $password = "&lt;password&gt;"; t t
 $message = "&lt;message content&gt;";
 $url = '&lt;API URL&gt;';
 $curl_handle = curl_init();
 curl_setopt($curl_handle, CURLOPT_URL, "$url");
 curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
 curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($curl_handle, CURLOPT_POST, 1);
 curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message");
 curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
 $buffer = curl_exec($curl_handle);
 curl_close($curl_handle);
?&gt;
</pre>
<p>If you&#8217;re looking for more info on how to use twitter, check out this <a href="http://80c59e-ex0t7s56uh6dma2cr3p.hop.clickbank.net/" target="_blank">eSeries</a>.  It&#8217;s a good resource.</p>
<p>So, have questions?  Let me know.  I&#8217;m hoping to do a twitter series soon!</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li style="clear: both;"><a href="http://www.jtgraphic.net/code/june-2010-pr-checker-php-script/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="June 2010 PR Checker PHP Script" title="June 2010 PR Checker PHP Script" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/code/june-2010-pr-checker-php-script/" rel="bookmark" class="crp_title">June 2010 PR Checker PHP Script</a><span class="crp_excerpt"> &lt;?php
function StrToNum($Str, $Check, $Magic)
{
 $Int32Unit = 4294967296;  // 2^32
 
 $length = strlen($Str);
 for ($i = 0; $i &lt; $length; ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2008/12/january-2009-contest-twitterlicious/" rel="bookmark"><img width="50" height="30" src="http://www.jtgraphic.net/wp-content/twitter-bird-pic-300x180.jpg" class="crp_thumb wp-post-image" alt="January 2009 Contest: Twitterlicious" title="January 2009 Contest: Twitterlicious" border="0" /></a> <a href="http://www.jtgraphic.net/2008/12/january-2009-contest-twitterlicious/" rel="bookmark" class="crp_title">January 2009 Contest: Twitterlicious</a><span class="crp_excerpt"> Description
Every month, I do a contest of sorts for free shirts from shirt.woot.  This month I want to focus on ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2010/01/bill-gates-twitter/" rel="bookmark"><img width="50" height="50" src="http://www.jtgraphic.net/wp-content/billgates_ss-150x150.jpg" class="crp_thumb wp-post-image" alt="Bill Gates is on Twitter" title="Bill Gates is on Twitter" border="0" /></a> <a href="http://www.jtgraphic.net/2010/01/bill-gates-twitter/" rel="bookmark" class="crp_title">Bill Gates is on Twitter</a><span class="crp_excerpt"> Oddly, I find it somewhat amusing that Bill Gates (@billgates) is getting into twitter so late in the game.  ...</span></li></ul></div><p><a href="http://www.jtgraphic.net/2010/02/twitter-api/">The Twitter API</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F02%2Ftwitter-api%2F&amp;title=The%20Twitter%20API&amp;bodytext=I%27ve%20been%20messing%20with%20the%20Twitter%20API%20for%20the%20first%20time%20in%20the%20last%20few%20hours%2C%20and%20I%27ve%20learned%20a%20TON.%C2%A0%20I%20know%20-%20I%27m%20jumping%20on%20the%20bandwagon%20late%2C%20but%20oh%20well.%C2%A0%20I%20managed%20to%20create%20a%20script%20to%20retweet%20%22stuff%22%20based%20on%20the%20search%20functionality%20an" title="Digg"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F02%2Ftwitter-api%2F&amp;title=The%20Twitter%20API&amp;notes=I%27ve%20been%20messing%20with%20the%20Twitter%20API%20for%20the%20first%20time%20in%20the%20last%20few%20hours%2C%20and%20I%27ve%20learned%20a%20TON.%C2%A0%20I%20know%20-%20I%27m%20jumping%20on%20the%20bandwagon%20late%2C%20but%20oh%20well.%C2%A0%20I%20managed%20to%20create%20a%20script%20to%20retweet%20%22stuff%22%20based%20on%20the%20search%20functionality%20an" title="del.icio.us"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=facebook-post&t=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F02%2Ftwitter-api%2F&d=http://www.facebook.com/share.php?u=TARGET%26t=The%20Twitter%20API" title="Facebook"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F02%2Ftwitter-api%2F&amp;title=The%20Twitter%20API" title="Mixx"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F02%2Ftwitter-api%2F&amp;title=The%20Twitter%20API&amp;annotation=I%27ve%20been%20messing%20with%20the%20Twitter%20API%20for%20the%20first%20time%20in%20the%20last%20few%20hours%2C%20and%20I%27ve%20learned%20a%20TON.%C2%A0%20I%20know%20-%20I%27m%20jumping%20on%20the%20bandwagon%20late%2C%20but%20oh%20well.%C2%A0%20I%20managed%20to%20create%20a%20script%20to%20retweet%20%22stuff%22%20based%20on%20the%20search%20functionality%20an" title="Google Bookmarks"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F02%2Ftwitter-api%2F&amp;title=The%20Twitter%20API" title="StumbleUpon"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F02%2Ftwitter-api%2F" title="Technorati"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=myspace&t=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F02%2Ftwitter-api%2F&d=http://www.myspace.com/Modules/PostTo/Pages/?u=TARGET%26t=The%20Twitter%20API" title="MySpace"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=twitter&t=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F02%2Ftwitter-api%2F&d=http://twitter.com/home?status=The%20Twitter%20API%20-%20TARGET" title="Twitter"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F02%2Ftwitter-api%2F" title="Sphinn"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F02%2Ftwitter-api%2F&amp;title=The%20Twitter%20API" title="Reddit"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.jtgraphic.net/2010/02/twitter-api/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Tidbit Tuesday on PHP: Simple MySQL Database Insert Function</title>
		<link>http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-insert-function/</link>
		<comments>http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-insert-function/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 19:03:49 +0000</pubDate>
		<dc:creator>James Thompson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[insert]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[return]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[Tidbit Tuesday]]></category>

		<guid isPermaLink="false">http://www.jtgraphic.net/?p=460</guid>
		<description><![CDATA[
			
				
			
		
<p>This builds on a function I did last week: db_query().  You can send any array straight to a MySQL database and it&#8217;ll even check to make sure the column actually exists.  Oh, and it returns the id of the record you just added in case you needed it.</p>
&#60;?php
   function db_array_insert($cfg_array, $table, $array) {
 <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-insert-function/">Tidbit Tuesday on PHP: Simple MySQL Database Insert Function</a></span><p><a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-insert-function/">Tidbit Tuesday on PHP: Simple MySQL Database Insert Function</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>
]]></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.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-insert-function%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-insert-function%2F&amp;source=jtgraphic&amp;style=normal&amp;service=bit.ly&amp;hashtags=array,database,function,How,if,insert,MySQL,PHP,Programming,return,SQL,table,Tidbit+Tuesday" height="61" width="50" /><br />
			</a>
		</div>
<p>This builds on a function I did last week: <a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-query-function/" target="_blank">db_query()</a>.  You can send any array straight to a MySQL database and it&#8217;ll even check to make sure the column actually exists.  Oh, and it returns the id of the record you just added in case you needed it.</p>
<pre class="brush: php">&lt;?php
   function db_array_insert($cfg_array, $table, $array) {
      require_once("dbQuery.function");

      $sql = "show columns from ".$table
      $tableArray = db_query($cfg_array, $sql);
      $inputString = "";

      foreach($tableArray as $key =&gt; $value) {
         if (array_key_exists($value[0], $array) &amp;&amp; $value[0])
            $inputString .= "'".addslashes($array[$value[0]])."', ";
         else
            $inputString .= "'', ";
      }

      $inputString = substr($inputString, 0, -2);
      $sql = "insert into $table values(".$inputString.")"
      db_query($cfg_array, $sql);

      return mysql_insert_id();
   }

   $insert_array = array(
      "column_1" =&gt; "something_1",
      "column_2" =&gt; "something_2"
   );

   $cfg_array = array(
      "db_loc" =&gt; 'www.databaselocation.com',
      "db_user" =&gt; 'some user'
      "db_pass" =&gt; 'some password'
      "db_name" =&gt; 'database_name_here'
   );

   db_array_insert($cfg_array, "some_table", $insert_array); //and use it.
?&gt;
</pre>
<p>So what do you think?  Having a problem?  Just let me know in the comments.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-query-function/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="Tidbit Tuesday on PHP: Simple MySQL Database Query Function" title="Tidbit Tuesday on PHP: Simple MySQL Database Query Function" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-query-function/" rel="bookmark" class="crp_title">Tidbit Tuesday on PHP: Simple MySQL Database Query Function</a><span class="crp_excerpt"> It's always great to create functions for those things you do a lot.  Probably the single most common function I ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/10/tidbit-tuesday-php-holiday-notices-business-sites/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="Tidbit Tuesday on PHP: Holiday Notices for Business Sites" title="Tidbit Tuesday on PHP: Holiday Notices for Business Sites" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/10/tidbit-tuesday-php-holiday-notices-business-sites/" rel="bookmark" class="crp_title">Tidbit Tuesday on PHP: Holiday Notices for Business Sites</a><span class="crp_excerpt"> This is a handy script for managing an out of office message on your website.  I find this very useful ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/08/pathfinding-php/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="Pathfinding in PHP" title="Pathfinding in PHP" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/08/pathfinding-php/" rel="bookmark" class="crp_title">Pathfinding in PHP</a><span class="crp_excerpt"> I've been playing around with doing some A* pathfinding scripts.  I was looking around on the web and didn't find ...</span></li></ul></div><p><a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-insert-function/">Tidbit Tuesday on PHP: Simple MySQL Database Insert Function</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-insert-function%2F&amp;title=Tidbit%20Tuesday%20on%20PHP%3A%20Simple%20MySQL%20Database%20Insert%20Function&amp;bodytext=This%20builds%20on%20a%20function%20I%20did%20last%20week%3A%20db_query%28%29.%20%20You%20can%20send%20any%20array%20straight%20to%20a%20MySQL%20database%20and%20it%27ll%20even%20check%20to%20make%20sure%20the%20column%20actually%20exists.%C2%A0%20Oh%2C%20and%20it%20returns%20the%20id%20of%20the%20record%20you%20just%20added%20in%20case%20you%20needed%20it.%0D" title="Digg"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-insert-function%2F&amp;title=Tidbit%20Tuesday%20on%20PHP%3A%20Simple%20MySQL%20Database%20Insert%20Function&amp;notes=This%20builds%20on%20a%20function%20I%20did%20last%20week%3A%20db_query%28%29.%20%20You%20can%20send%20any%20array%20straight%20to%20a%20MySQL%20database%20and%20it%27ll%20even%20check%20to%20make%20sure%20the%20column%20actually%20exists.%C2%A0%20Oh%2C%20and%20it%20returns%20the%20id%20of%20the%20record%20you%20just%20added%20in%20case%20you%20needed%20it.%0D" title="del.icio.us"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=facebook-post&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-insert-function%2F&d=http://www.facebook.com/share.php?u=TARGET%26t=Tidbit%20Tuesday%20on%20PHP%3A%20Simple%20MySQL%20Database%20Insert%20Function" title="Facebook"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-insert-function%2F&amp;title=Tidbit%20Tuesday%20on%20PHP%3A%20Simple%20MySQL%20Database%20Insert%20Function" title="Mixx"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-insert-function%2F&amp;title=Tidbit%20Tuesday%20on%20PHP%3A%20Simple%20MySQL%20Database%20Insert%20Function&amp;annotation=This%20builds%20on%20a%20function%20I%20did%20last%20week%3A%20db_query%28%29.%20%20You%20can%20send%20any%20array%20straight%20to%20a%20MySQL%20database%20and%20it%27ll%20even%20check%20to%20make%20sure%20the%20column%20actually%20exists.%C2%A0%20Oh%2C%20and%20it%20returns%20the%20id%20of%20the%20record%20you%20just%20added%20in%20case%20you%20needed%20it.%0D" title="Google Bookmarks"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-insert-function%2F&amp;title=Tidbit%20Tuesday%20on%20PHP%3A%20Simple%20MySQL%20Database%20Insert%20Function" title="StumbleUpon"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-insert-function%2F" title="Technorati"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=myspace&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-insert-function%2F&d=http://www.myspace.com/Modules/PostTo/Pages/?u=TARGET%26t=Tidbit%20Tuesday%20on%20PHP%3A%20Simple%20MySQL%20Database%20Insert%20Function" title="MySpace"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=twitter&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-insert-function%2F&d=http://twitter.com/home?status=Tidbit%20Tuesday%20on%20PHP%3A%20Simple%20MySQL%20Database%20Insert%20Function%20-%20TARGET" title="Twitter"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-insert-function%2F" title="Sphinn"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-insert-function%2F&amp;title=Tidbit%20Tuesday%20on%20PHP%3A%20Simple%20MySQL%20Database%20Insert%20Function" title="Reddit"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-insert-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tidbit Tuesday on PHP: Simple MySQL Database Query Function</title>
		<link>http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-query-function/</link>
		<comments>http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-query-function/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 17:28:20 +0000</pubDate>
		<dc:creator>James Thompson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[db_query]]></category>
		<category><![CDATA[die]]></category>
		<category><![CDATA[foreach]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[mysql_connect]]></category>
		<category><![CDATA[mysql_error]]></category>
		<category><![CDATA[mysql_query]]></category>
		<category><![CDATA[mysql_select_db]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[select]]></category>
		<category><![CDATA[Tidbit Tuesday]]></category>

		<guid isPermaLink="false">http://www.jtgraphic.net/?p=452</guid>
		<description><![CDATA[
			
				
			
		
<p>It&#8217;s always great to create functions for those things you do a lot.  Probably the single most common function I execute is database calls.</p>
<p>Here is a simple script for hitting up your MySQL database with a query:</p>

&#60;?php
   if(!function_exists(dbQuery)) {
      function db_query($cfg_array, $query) {
       <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-query-function/">Tidbit Tuesday on PHP: Simple MySQL Database Query Function</a></span><p><a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-query-function/">Tidbit Tuesday on PHP: Simple MySQL Database Query Function</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>
]]></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.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-query-function%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-query-function%2F&amp;source=jtgraphic&amp;style=normal&amp;service=bit.ly&amp;hashtags=db_query,die,foreach,MySQL,mysql_connect,mysql_error,mysql_query,mysql_select_db,PHP,Programming,query,select,Tidbit+Tuesday" height="61" width="50" /><br />
			</a>
		</div>
<p>It&#8217;s always great to create functions for those things you do a lot.  Probably the single most common function I execute is database calls.</p>
<p>Here is a simple script for hitting up your MySQL database with a query:</p>
<pre class="brush: php">
&lt;?php
   if(!function_exists(dbQuery)) {
      function db_query($cfg_array, $query) {
         $connection =
            mysql_connect(
               $cfg_array['db_loc'],$cfg_array['db_user'],$cfg_array['db_pass']
            ) or die(mysql_error());

         mysql_select_db($cfg_array['db_name'],$connection)
            or die(mysql_error()." &gt;&gt; ".$query);
         $result = mysql_query($query,$connection)
            or die (mysql_error()." &gt;&gt; ".$query);
         $i = 0;

         if($result != 1) {
            while ($data_array = mysql_fetch_array($result)) {
               foreach($data_array as $key =&gt; $value) {
                  $tableArray[$i][$key] = stripslashes($data_array[$key]);
               }

               $i++;
            }

            return $tableArray;
         }
      }
   }
?&gt;
</pre>
<p>You should be able to just copy and paste this as a function and call it in one of two ways:</p>
<pre class="brush: php">
$cfg_array = array(
   "db_loc" =&gt; 'www.databaselocation.com',
   "db_user" =&gt; 'some user'
   "db_pass" =&gt; 'some password'
   "db_name" =&gt; 'database_name_here'
);

$query = "SELECT * FROM 'table' WHERE some_column = 'something'";

db_query($cfg_array, $query); // This will return an array with the table in it.

$query = "UPDATE/DELETE/ETC * FROM 'table' WHERE some_column = 'something'";

db_query($cfg_array, $query); // This will return return an empty array, but still works.
</pre>
<p>I use this function in EVERYTHING.  I also have some other functions that use this as its base.  Someday I&#8217;ll turn it into a class.</p>
<p>So, what do you think?</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-insert-function/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="Tidbit Tuesday on PHP: Simple MySQL Database Insert Function" title="Tidbit Tuesday on PHP: Simple MySQL Database Insert Function" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-insert-function/" rel="bookmark" class="crp_title">Tidbit Tuesday on PHP: Simple MySQL Database Insert Function</a><span class="crp_excerpt"> This builds on a function I did last week: db_query().  You can send any array straight to a MySQL ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/code/june-2010-pr-checker-php-script/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="June 2010 PR Checker PHP Script" title="June 2010 PR Checker PHP Script" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/code/june-2010-pr-checker-php-script/" rel="bookmark" class="crp_title">June 2010 PR Checker PHP Script</a><span class="crp_excerpt"> &lt;?php
function StrToNum($Str, $Check, $Magic)
{
 $Int32Unit = 4294967296;  // 2^32
 
 $length = strlen($Str);
 for ($i = 0; $i &lt; $length; ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/10/tidbit-tuesday-php-holiday-notices-business-sites/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="Tidbit Tuesday on PHP: Holiday Notices for Business Sites" title="Tidbit Tuesday on PHP: Holiday Notices for Business Sites" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/10/tidbit-tuesday-php-holiday-notices-business-sites/" rel="bookmark" class="crp_title">Tidbit Tuesday on PHP: Holiday Notices for Business Sites</a><span class="crp_excerpt"> This is a handy script for managing an out of office message on your website.  I find this very useful ...</span></li></ul></div><p><a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-query-function/">Tidbit Tuesday on PHP: Simple MySQL Database Query Function</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-query-function%2F&amp;title=Tidbit%20Tuesday%20on%20PHP%3A%20Simple%20MySQL%20Database%20Query%20Function&amp;bodytext=It%27s%20always%20great%20to%20create%20functions%20for%20those%20things%20you%20do%20a%20lot.%C2%A0%20Probably%20the%20single%20most%20common%20function%20I%20execute%20is%20database%20calls.%0D%0A%0D%0AHere%20is%20a%20simple%20script%20for%20hitting%20up%20your%20MySQL%20database%20with%20a%20query%3A%0D%0A%0D%0A%26lt%3B%3Fphp%0D%0A%20%20%20if%28%21function_exis" title="Digg"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-query-function%2F&amp;title=Tidbit%20Tuesday%20on%20PHP%3A%20Simple%20MySQL%20Database%20Query%20Function&amp;notes=It%27s%20always%20great%20to%20create%20functions%20for%20those%20things%20you%20do%20a%20lot.%C2%A0%20Probably%20the%20single%20most%20common%20function%20I%20execute%20is%20database%20calls.%0D%0A%0D%0AHere%20is%20a%20simple%20script%20for%20hitting%20up%20your%20MySQL%20database%20with%20a%20query%3A%0D%0A%0D%0A%26lt%3B%3Fphp%0D%0A%20%20%20if%28%21function_exis" title="del.icio.us"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=facebook-post&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-query-function%2F&d=http://www.facebook.com/share.php?u=TARGET%26t=Tidbit%20Tuesday%20on%20PHP%3A%20Simple%20MySQL%20Database%20Query%20Function" title="Facebook"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-query-function%2F&amp;title=Tidbit%20Tuesday%20on%20PHP%3A%20Simple%20MySQL%20Database%20Query%20Function" title="Mixx"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-query-function%2F&amp;title=Tidbit%20Tuesday%20on%20PHP%3A%20Simple%20MySQL%20Database%20Query%20Function&amp;annotation=It%27s%20always%20great%20to%20create%20functions%20for%20those%20things%20you%20do%20a%20lot.%C2%A0%20Probably%20the%20single%20most%20common%20function%20I%20execute%20is%20database%20calls.%0D%0A%0D%0AHere%20is%20a%20simple%20script%20for%20hitting%20up%20your%20MySQL%20database%20with%20a%20query%3A%0D%0A%0D%0A%26lt%3B%3Fphp%0D%0A%20%20%20if%28%21function_exis" title="Google Bookmarks"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-query-function%2F&amp;title=Tidbit%20Tuesday%20on%20PHP%3A%20Simple%20MySQL%20Database%20Query%20Function" title="StumbleUpon"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-query-function%2F" title="Technorati"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=myspace&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-query-function%2F&d=http://www.myspace.com/Modules/PostTo/Pages/?u=TARGET%26t=Tidbit%20Tuesday%20on%20PHP%3A%20Simple%20MySQL%20Database%20Query%20Function" title="MySpace"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=twitter&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-query-function%2F&d=http://twitter.com/home?status=Tidbit%20Tuesday%20on%20PHP%3A%20Simple%20MySQL%20Database%20Query%20Function%20-%20TARGET" title="Twitter"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-query-function%2F" title="Sphinn"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F11%2Ftidbit-tuesday-php-simple-mysql-database-query-function%2F&amp;title=Tidbit%20Tuesday%20on%20PHP%3A%20Simple%20MySQL%20Database%20Query%20Function" title="Reddit"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-query-function/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tidbit Tuesday on PHP: Holiday Notices for Business Sites</title>
		<link>http://www.jtgraphic.net/2009/10/tidbit-tuesday-php-holiday-notices-business-sites/</link>
		<comments>http://www.jtgraphic.net/2009/10/tidbit-tuesday-php-holiday-notices-business-sites/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 20:47:48 +0000</pubDate>
		<dc:creator>James Thompson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[2009]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[Calendar]]></category>
		<category><![CDATA[Custom Functions]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[strtotime]]></category>
		<category><![CDATA[Tidbit Tuesday]]></category>

		<guid isPermaLink="false">http://www.jtgraphic.net/?p=343</guid>
		<description><![CDATA[
			
				
			
		
<p>This is a handy script for managing an out of office message on your website.  I find this very useful on business websites when you&#8217;re tired of making that one little change to let people know when the office will be shut down.  With about 15 minutes of extra work, you only need to do it <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.jtgraphic.net/2009/10/tidbit-tuesday-php-holiday-notices-business-sites/">Tidbit Tuesday on PHP: Holiday Notices for Business Sites</a></span><p><a href="http://www.jtgraphic.net/2009/10/tidbit-tuesday-php-holiday-notices-business-sites/">Tidbit Tuesday on PHP: Holiday Notices for Business Sites</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>
]]></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.jtgraphic.net%2F2009%2F10%2Ftidbit-tuesday-php-holiday-notices-business-sites%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Ftidbit-tuesday-php-holiday-notices-business-sites%2F&amp;source=jtgraphic&amp;style=normal&amp;service=bit.ly&amp;hashtags=2009,array,Calendar,Custom+Functions,if,PHP,Programming,strtotime,Tidbit+Tuesday" height="61" width="50" /><br />
			</a>
		</div>
<p>This is a handy script for managing an out of office message on your website.  I find this very useful on business websites when you&#8217;re tired of making that one little change to let people know when the office will be shut down.  With about 15 minutes of extra work, you only need to do it once a year.</p>
<p>Let&#8217;s say for instance we&#8217;re doing all of the major U.S. Holidays in 2010, observing weekend Holidays with a day off on either side of the weekend.  This means first we need to determine what those dates are.  I just happen to have looked up the six most common, listed below:</p>
<ul>
<li>New Year&#8217;s Eve &#8211; January 1st</li>
<li>Memorial Day &#8211; May 31st</li>
<li>Independence Day &#8211; July 5th (July 4th is Sunday)</li>
<li>Labor Day &#8211; September 6th</li>
<li>Thanksgiving &#8211; November 25th and 26th</li>
<li>Christmas &#8211; December 24th (December 25th is a Saturday)</li>
</ul>
<p>Now that we know our dates, we can build them into an array:</p>
<pre>$date_array = array(
   "New Yearís Eve" =&gt;
      array("leaving" =&gt; "2010-12-31", "returning" =&gt; "2011-01-03"),
   "Memorial Day" =&gt;
      array("leaving" =&gt; "2010-05-31", "returning" =&gt; "2010-06-01"),
   "Independence Day" =&gt; // July 4th is a Sunday
      array("leaving" =&gt; "2010-07-05", "returning" =&gt; "2010-07-06"),
   "Labor Day" =&gt;
      array("leaving" =&gt; "2010-09-06", "returning" =&gt; "2010-09-07"),
   "Thanksgiving" =&gt;
      array("leaving" =&gt; "2010-11-025", "returning" =&gt; "2010-11-029"),
   "Christmas" =&gt; // December 25th is a Saturday
      array("leaving" =&gt; "2010-12-24", "returning" =&gt; "2010-12-27"),
 );</pre>
<p>The date array can easily be stored in a database or be made up of more complicated functions that would calculate the holidays across multiple years with some basic logic.  Maybe we&#8217;ll cover the latter part in another post some day.</p>
<p>Now we need to build the function itself.  This function will be run every time the page loads.  You can even include the function in a separate file to be included on multiple pages:</p>
<pre>function holiday_message($date, $date_array) {
   $date = strtotime($date); // Reformat the date so we can do math on it.
   foreach($date_array as $key =&gt; $value) {
      $leaving = strtotime($value['leaving']);
      $returning = strtotime($value['returning']);
      $early_warning = $leaving - 86400 * 7;
      // If the date is between (7 days before) leaving and returning
         if($date &gt; $early_warning &amp;&amp; $date &lt; $returning) {
            echo
               "We will be observing ".$key." from ".date("Y-m-d", $leaving).
               " until ". date("Y-m-d", $returning).".
               When we return we will be more than happy to assist you.";
         }
   }
}</pre>
<p>Now we just need to execute this function anywhere on the page:</p>
<pre>holiday_message(date("Y-m-d H:i:s"),$date_array);</pre>
<p>This code can be customized in numerous different ways, so the the message is more formal, or works for your specific situation.  You can also change the way days are stored or calculated, like the example above.  This is a core to get you started.  Where can you go from here?</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/10/php-function-friday-date/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="PHP Function Friday: date" title="PHP Function Friday: date" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/10/php-function-friday-date/" rel="bookmark" class="crp_title">PHP Function Friday: date</a><span class="crp_excerpt"> I think the date function is extremely useful.  It gives your programs an awareness of WHEN they are.  You can ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/09/php-function-friday-function/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="PHP Function Friday: function" title="PHP Function Friday: function" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/09/php-function-friday-function/" rel="bookmark" class="crp_title">PHP Function Friday: function</a><span class="crp_excerpt"> So, I've decided to start including a new post every Friday - kind of as a discipline thing.  I'm ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-insert-function/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="Tidbit Tuesday on PHP: Simple MySQL Database Insert Function" title="Tidbit Tuesday on PHP: Simple MySQL Database Insert Function" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-insert-function/" rel="bookmark" class="crp_title">Tidbit Tuesday on PHP: Simple MySQL Database Insert Function</a><span class="crp_excerpt"> This builds on a function I did last week: db_query().  You can send any array straight to a MySQL ...</span></li></ul></div><p><a href="http://www.jtgraphic.net/2009/10/tidbit-tuesday-php-holiday-notices-business-sites/">Tidbit Tuesday on PHP: Holiday Notices for Business Sites</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Ftidbit-tuesday-php-holiday-notices-business-sites%2F&amp;title=Tidbit%20Tuesday%20on%20PHP%3A%20Holiday%20Notices%20for%20Business%20Sites&amp;bodytext=This%20is%20a%20handy%20script%20for%20managing%20an%20out%20of%20office%20message%20on%20your%20website.%C2%A0%20I%20find%20this%20very%20useful%20on%20business%20websites%20when%20you%27re%20tired%20of%20making%20that%20one%20little%20change%20to%20let%20people%20know%20when%20the%20office%20will%20be%20shut%20down.%C2%A0%20With%20about%2015%20minu" title="Digg"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Ftidbit-tuesday-php-holiday-notices-business-sites%2F&amp;title=Tidbit%20Tuesday%20on%20PHP%3A%20Holiday%20Notices%20for%20Business%20Sites&amp;notes=This%20is%20a%20handy%20script%20for%20managing%20an%20out%20of%20office%20message%20on%20your%20website.%C2%A0%20I%20find%20this%20very%20useful%20on%20business%20websites%20when%20you%27re%20tired%20of%20making%20that%20one%20little%20change%20to%20let%20people%20know%20when%20the%20office%20will%20be%20shut%20down.%C2%A0%20With%20about%2015%20minu" title="del.icio.us"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=facebook-post&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Ftidbit-tuesday-php-holiday-notices-business-sites%2F&d=http://www.facebook.com/share.php?u=TARGET%26t=Tidbit%20Tuesday%20on%20PHP%3A%20Holiday%20Notices%20for%20Business%20Sites" title="Facebook"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Ftidbit-tuesday-php-holiday-notices-business-sites%2F&amp;title=Tidbit%20Tuesday%20on%20PHP%3A%20Holiday%20Notices%20for%20Business%20Sites" title="Mixx"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Ftidbit-tuesday-php-holiday-notices-business-sites%2F&amp;title=Tidbit%20Tuesday%20on%20PHP%3A%20Holiday%20Notices%20for%20Business%20Sites&amp;annotation=This%20is%20a%20handy%20script%20for%20managing%20an%20out%20of%20office%20message%20on%20your%20website.%C2%A0%20I%20find%20this%20very%20useful%20on%20business%20websites%20when%20you%27re%20tired%20of%20making%20that%20one%20little%20change%20to%20let%20people%20know%20when%20the%20office%20will%20be%20shut%20down.%C2%A0%20With%20about%2015%20minu" title="Google Bookmarks"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Ftidbit-tuesday-php-holiday-notices-business-sites%2F&amp;title=Tidbit%20Tuesday%20on%20PHP%3A%20Holiday%20Notices%20for%20Business%20Sites" title="StumbleUpon"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Ftidbit-tuesday-php-holiday-notices-business-sites%2F" title="Technorati"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=myspace&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Ftidbit-tuesday-php-holiday-notices-business-sites%2F&d=http://www.myspace.com/Modules/PostTo/Pages/?u=TARGET%26t=Tidbit%20Tuesday%20on%20PHP%3A%20Holiday%20Notices%20for%20Business%20Sites" title="MySpace"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=twitter&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Ftidbit-tuesday-php-holiday-notices-business-sites%2F&d=http://twitter.com/home?status=Tidbit%20Tuesday%20on%20PHP%3A%20Holiday%20Notices%20for%20Business%20Sites%20-%20TARGET" title="Twitter"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Ftidbit-tuesday-php-holiday-notices-business-sites%2F" title="Sphinn"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Ftidbit-tuesday-php-holiday-notices-business-sites%2F&amp;title=Tidbit%20Tuesday%20on%20PHP%3A%20Holiday%20Notices%20for%20Business%20Sites" title="Reddit"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.jtgraphic.net/2009/10/tidbit-tuesday-php-holiday-notices-business-sites/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>PHP Function Friday: date</title>
		<link>http://www.jtgraphic.net/2009/10/php-function-friday-date/</link>
		<comments>http://www.jtgraphic.net/2009/10/php-function-friday-date/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 04:02:01 +0000</pubDate>
		<dc:creator>James Thompson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[Function Friday]]></category>

		<guid isPermaLink="false">http://www.jtgraphic.net/?p=445</guid>
		<description><![CDATA[
			
				
			
		
<p>I think the date function is extremely useful.  It gives your programs an awareness of WHEN they are.  You can do some pretty cool things like calculate this date from that date, make a calendar, or store information about when an action was taken.</p>
Function and Syntax
string date(string $format  [, int $timestamp  ])
Manual Entry
<p>http://php.net/manual/en/function.date.php</p>
Notes and <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.jtgraphic.net/2009/10/php-function-friday-date/">PHP Function Friday: date</a></span><p><a href="http://www.jtgraphic.net/2009/10/php-function-friday-date/">PHP Function Friday: date</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>
]]></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.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-date%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-date%2F&amp;source=jtgraphic&amp;style=normal&amp;service=bit.ly&amp;hashtags=date,Function+Friday" height="61" width="50" /><br />
			</a>
		</div>
<p>I think the date function is extremely useful.  It gives your programs an awareness of WHEN they are.  You can do some pretty cool things like calculate this date from that date, make a calendar, or store information about when an action was taken.</p>
<h3>Function and Syntax</h3>
<pre class="brush: php">string date(string $format  [, int $timestamp  ])</pre>
<h3>Manual Entry</h3>
<p><a href="http://php.net/manual/en/function.date.php" target="_blank">http://php.net/manual/en/function.date.php</a></p>
<h3>Notes and Use</h3>
<p>There are two variables you can pass to the date function: the string format, and the timestamp.  What are those?  The string format uses various characters to define how the string the function returns will be formatted.  The table for which characters mean what is on the <a href="http://php.net/manual/en/function.date.php">PHP Manual Page</a>.  The timestamp is a Unix timestamp for a specific date/time.</p>
<h3>Other Functions Referenced in Examples</h3>
<ul>
<li><a href="http://php.net/manual/en/control-structures.if.php" target="_blank">if<br />
</a></li>
</ul>
<h3>Examples</h3>
<h4>Output Today&#8217;s Date and Time</h4>
<p>This should just simply output today&#8217;s date.  I did a few formats based on January 1, 2009 at 4:52:39 PM.</p>
<pre class="brush: php">echo date("Y-m-d H:i:s"); /* Should output '2009-01-01 16:52:39'.  Common programming format*/
echo date("F n, Y at g:m:s A") /* Should output 'January 1, 2009 at 4:52:39 PM'.*/
</pre>
<h4>Put a Message on Your Website Every Monday</h4>
<p>Do you hate Mondays?  Let everyone know.  This script checks to see if it&#8217;s Monday and then outputs a message if it is.  That &#8216;w&#8217; in the date function is a numeric representation of the day of the week.  For instance: Wednesday is 3 and Sunday is 0.</p>
<pre class="brush: php">if(date("w") == 1) {
   echo "Ugh.  It's Monday."
}
</pre>
<h3>Examples Elsewhere on this Site:</h3>
<p><a href="http://www.jtgraphic.net/2009/10/tidbit-tuesday-php-holiday-notices-business-sites/" target="_blank">Holiday Notices</a></p>
<h3>Conclusion</h3>
<p>Date functions are extremely useful when trying to figure out when you are (or better stated: when your program tries to figure out when it is).  Using date and time functions allow you to create a lot of automation in your scripts.  Have you got any useful implementations on this function?</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/09/php-function-friday-function/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="PHP Function Friday: function" title="PHP Function Friday: function" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/09/php-function-friday-function/" rel="bookmark" class="crp_title">PHP Function Friday: function</a><span class="crp_excerpt"> So, I've decided to start including a new post every Friday - kind of as a discipline thing.  I'm ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/10/tidbit-tuesday-php-holiday-notices-business-sites/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="Tidbit Tuesday on PHP: Holiday Notices for Business Sites" title="Tidbit Tuesday on PHP: Holiday Notices for Business Sites" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/10/tidbit-tuesday-php-holiday-notices-business-sites/" rel="bookmark" class="crp_title">Tidbit Tuesday on PHP: Holiday Notices for Business Sites</a><span class="crp_excerpt"> This is a handy script for managing an out of office message on your website.  I find this very useful ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/10/php-function-friday-include/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="PHP Function Friday: include" title="PHP Function Friday: include" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/10/php-function-friday-include/" rel="bookmark" class="crp_title">PHP Function Friday: include</a><span class="crp_excerpt"> Including files makes it really easy to NOT duplicate code.  It's great for creating headers and footers for websites, ...</span></li></ul></div><p><a href="http://www.jtgraphic.net/2009/10/php-function-friday-date/">PHP Function Friday: date</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-date%2F&amp;title=PHP%20Function%20Friday%3A%20date&amp;bodytext=I%20think%20the%20date%20function%20is%20extremely%20useful.%C2%A0%20It%20gives%20your%20programs%20an%20awareness%20of%20WHEN%20they%20are.%C2%A0%20You%20can%20do%20some%20pretty%20cool%20things%20like%20calculate%20this%20date%20from%20that%20date%2C%20make%20a%20calendar%2C%20or%20store%20information%20about%20when%20an%20action%20was%20taken." title="Digg"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-date%2F&amp;title=PHP%20Function%20Friday%3A%20date&amp;notes=I%20think%20the%20date%20function%20is%20extremely%20useful.%C2%A0%20It%20gives%20your%20programs%20an%20awareness%20of%20WHEN%20they%20are.%C2%A0%20You%20can%20do%20some%20pretty%20cool%20things%20like%20calculate%20this%20date%20from%20that%20date%2C%20make%20a%20calendar%2C%20or%20store%20information%20about%20when%20an%20action%20was%20taken." title="del.icio.us"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=facebook-post&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-date%2F&d=http://www.facebook.com/share.php?u=TARGET%26t=PHP%20Function%20Friday%3A%20date" title="Facebook"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-date%2F&amp;title=PHP%20Function%20Friday%3A%20date" title="Mixx"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-date%2F&amp;title=PHP%20Function%20Friday%3A%20date&amp;annotation=I%20think%20the%20date%20function%20is%20extremely%20useful.%C2%A0%20It%20gives%20your%20programs%20an%20awareness%20of%20WHEN%20they%20are.%C2%A0%20You%20can%20do%20some%20pretty%20cool%20things%20like%20calculate%20this%20date%20from%20that%20date%2C%20make%20a%20calendar%2C%20or%20store%20information%20about%20when%20an%20action%20was%20taken." title="Google Bookmarks"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-date%2F&amp;title=PHP%20Function%20Friday%3A%20date" title="StumbleUpon"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-date%2F" title="Technorati"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=myspace&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-date%2F&d=http://www.myspace.com/Modules/PostTo/Pages/?u=TARGET%26t=PHP%20Function%20Friday%3A%20date" title="MySpace"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=twitter&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-date%2F&d=http://twitter.com/home?status=PHP%20Function%20Friday%3A%20date%20-%20TARGET" title="Twitter"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-date%2F" title="Sphinn"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-date%2F&amp;title=PHP%20Function%20Friday%3A%20date" title="Reddit"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.jtgraphic.net/2009/10/php-function-friday-date/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Function Friday: include</title>
		<link>http://www.jtgraphic.net/2009/10/php-function-friday-include/</link>
		<comments>http://www.jtgraphic.net/2009/10/php-function-friday-include/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 21:52:28 +0000</pubDate>
		<dc:creator>James Thompson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Function Friday]]></category>
		<category><![CDATA[include]]></category>

		<guid isPermaLink="false">http://www.jtgraphic.net/?p=421</guid>
		<description><![CDATA[
			
				
			
		
<p>Including files makes it really easy to NOT duplicate code.  It&#8217;s great for creating headers and footers for websites, or using it in the inverse: make the header and footer in one file, and include the content.  You can also store site configuration files, functions, and repeating content, etc.</p>
Function and Syntax
include(&#60;file path&#62;);

Manual Entry
<p>http://php.net/manual/en/function.include.php</p>
Notes and Use
<p>Includes <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.jtgraphic.net/2009/10/php-function-friday-include/">PHP Function Friday: include</a></span><p><a href="http://www.jtgraphic.net/2009/10/php-function-friday-include/">PHP Function Friday: include</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>
]]></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.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-include%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-include%2F&amp;source=jtgraphic&amp;style=normal&amp;service=bit.ly&amp;hashtags=Function+Friday,include" height="61" width="50" /><br />
			</a>
		</div>
<p>Including files makes it really easy to NOT duplicate code.  It&#8217;s great for creating headers and footers for websites, or using it in the inverse: make the header and footer in one file, and include the content.  You can also store site configuration files, functions, and repeating content, etc.</p>
<h3>Function and Syntax</h3>
<pre class="brush: php">include(&lt;file path&gt;);
</pre>
<h3>Manual Entry</h3>
<p><a href="http://php.net/manual/en/function.include.php">http://php.net/manual/en/function.include.php</a></p>
<h3>Notes and Use</h3>
<p>Includes are a great way to include the same code to many different PHP files.  I find this the most useful for storing variables and functions across an entire website.  The other great way to use this function is to include repetitive code that needs to be outside of a function scope &#8211; for example: including form layouts across multiple pages.  I like to use the same include for both my add and edit pages on a form sometimes.</p>
<h3>Examples</h3>
<h4>Storing Site-Wide Variables</h4>
<p>This is stored in the file &#8216;configuration.php&#8217;:</p>
<pre class="brush: php">$blog_name = "jtGraphic.net";
$blog_description = "Ramblings of an Internet Addict";
</pre>
<p>This is another PHP file where you&#8217;re calling the include &#8211; call it whatever you want.  I&#8217;ll call mine &#8216;main.php&#8217;:</p>
<pre class="brush: php">include("configuration.php");
echo $blog_name."&lt;br /&gt;";
echo $blog_description;
</pre>
<p>This is another PHP file somewhere else on the site &#8211; maybe inside the /content/ directory.  Call it whatever you want.  I&#8217;ll call mine &#8216;content.php&#8217;:</p>
<pre class="brush: php">include("../configuration.php");
echo $blog_name."&lt;br /&gt;";
echo $blog_description;
</pre>
<p>Both &#8216;main.php&#8217; and &#8216;content.php&#8217; will echo out the same information because you included the same file at the beginning of each.</p>
<h4>Website Header and Footer</h4>
<p>I find that another extremely powerful use of includes is to build your header and footer for your website.  In this example, we&#8217;re going to dynamically set the title variable in the main content page and call it inside the include.  This is how I build some of my simpler sites.  By the way, this isn&#8217;t HTML standards compliant.  It&#8217;s just an example.</p>
<p>We&#8217;ll call this file &#8216;header.php&#8217;</p>
<pre class="brush: php">&lt;html&gt;
   &lt;head&gt;
      &lt;title&gt;jtGraphic.net &lt;?php echo $page_title; ?&gt;&lt;/title&gt;
   &lt;/head&gt;
   &lt;body&gt;
/*snip*/
</pre>
<p>We&#8217;ll call this next file &#8216;footer.php&#8217;;</p>
<pre class="brush: php">//snip
      &lt;div&gt; &amp;copy; James Thompson and jtGraphic.net &lt;/div&gt;
   &lt;body&gt;
&lt;/html&gt;
</pre>
<p>Now that we have our header and footer, we can make some more pages:</p>
<p>We&#8217;ll call this one &#8216;content_1.php&#8217;:</p>
<pre class="brush: php">$page_title = "Some Title";
include("header.php");
//content here
include("footer.php");
</pre>
<p>We&#8217;ll call the next one &#8216;content_2.php&#8217;:</p>
<pre class="brush: php">$page_title = "Some Other Title";
include("header.php");
//content here
include("footer.php");
</pre>
<p>When accessing &#8216;content_1.php&#8217; and &#8216;content_2.php&#8217; you should get everything you put in &#8216;header.php&#8217; and &#8216;footer.php&#8217;, but the title should be what you defined in the content files.  This is a really rudimentary example, but it is VERY useful.</p>
<h3>Conclusion</h3>
<p>So, remember: whenever you have a set of code that is duplicated you can probably deal with it through <a href="http://www.jtgraphic.net/2009/09/php-function-friday-function/" target="_blank">custom functions</a> or includes.  Don&#8217;t duplicate the code!  If you have your own examples, feel free to link them up below!</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/10/php-function-friday-date/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="PHP Function Friday: date" title="PHP Function Friday: date" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/10/php-function-friday-date/" rel="bookmark" class="crp_title">PHP Function Friday: date</a><span class="crp_excerpt"> I think the date function is extremely useful.  It gives your programs an awareness of WHEN they are.  You can ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/09/php-function-friday-function/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="PHP Function Friday: function" title="PHP Function Friday: function" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/09/php-function-friday-function/" rel="bookmark" class="crp_title">PHP Function Friday: function</a><span class="crp_excerpt"> So, I've decided to start including a new post every Friday - kind of as a discipline thing.  I'm ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/10/tidbit-tuesday-php-holiday-notices-business-sites/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="Tidbit Tuesday on PHP: Holiday Notices for Business Sites" title="Tidbit Tuesday on PHP: Holiday Notices for Business Sites" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/10/tidbit-tuesday-php-holiday-notices-business-sites/" rel="bookmark" class="crp_title">Tidbit Tuesday on PHP: Holiday Notices for Business Sites</a><span class="crp_excerpt"> This is a handy script for managing an out of office message on your website.  I find this very useful ...</span></li></ul></div><p><a href="http://www.jtgraphic.net/2009/10/php-function-friday-include/">PHP Function Friday: include</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-include%2F&amp;title=PHP%20Function%20Friday%3A%20include&amp;bodytext=Including%20files%20makes%20it%20really%20easy%20to%20NOT%20duplicate%20code.%20%20It%27s%20great%20for%20creating%20headers%20and%20footers%20for%20websites%2C%20or%20using%20it%20in%20the%20inverse%3A%20make%20the%20header%20and%20footer%20in%20one%20file%2C%20and%20include%20the%20content.%C2%A0%20You%20can%20also%20store%20site%20configuratio" title="Digg"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-include%2F&amp;title=PHP%20Function%20Friday%3A%20include&amp;notes=Including%20files%20makes%20it%20really%20easy%20to%20NOT%20duplicate%20code.%20%20It%27s%20great%20for%20creating%20headers%20and%20footers%20for%20websites%2C%20or%20using%20it%20in%20the%20inverse%3A%20make%20the%20header%20and%20footer%20in%20one%20file%2C%20and%20include%20the%20content.%C2%A0%20You%20can%20also%20store%20site%20configuratio" title="del.icio.us"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=facebook-post&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-include%2F&d=http://www.facebook.com/share.php?u=TARGET%26t=PHP%20Function%20Friday%3A%20include" title="Facebook"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-include%2F&amp;title=PHP%20Function%20Friday%3A%20include" title="Mixx"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-include%2F&amp;title=PHP%20Function%20Friday%3A%20include&amp;annotation=Including%20files%20makes%20it%20really%20easy%20to%20NOT%20duplicate%20code.%20%20It%27s%20great%20for%20creating%20headers%20and%20footers%20for%20websites%2C%20or%20using%20it%20in%20the%20inverse%3A%20make%20the%20header%20and%20footer%20in%20one%20file%2C%20and%20include%20the%20content.%C2%A0%20You%20can%20also%20store%20site%20configuratio" title="Google Bookmarks"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-include%2F&amp;title=PHP%20Function%20Friday%3A%20include" title="StumbleUpon"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-include%2F" title="Technorati"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=myspace&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-include%2F&d=http://www.myspace.com/Modules/PostTo/Pages/?u=TARGET%26t=PHP%20Function%20Friday%3A%20include" title="MySpace"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=twitter&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-include%2F&d=http://twitter.com/home?status=PHP%20Function%20Friday%3A%20include%20-%20TARGET" title="Twitter"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-include%2F" title="Sphinn"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F10%2Fphp-function-friday-include%2F&amp;title=PHP%20Function%20Friday%3A%20include" title="Reddit"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.jtgraphic.net/2009/10/php-function-friday-include/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Function Friday: function</title>
		<link>http://www.jtgraphic.net/2009/09/php-function-friday-function/</link>
		<comments>http://www.jtgraphic.net/2009/09/php-function-friday-function/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 00:29:43 +0000</pubDate>
		<dc:creator>James Thompson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[Function Friday]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Link]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[return]]></category>
		<category><![CDATA[strtotime]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.jtgraphic.net/?p=368</guid>
		<description><![CDATA[
			
				
			
		
<p>So, I&#8217;ve decided to start including a new post every Friday &#8211; kind of as a discipline thing.  I&#8217;m going to write a post on a PHP function every Friday.  I&#8217;m not just going to regurgitate the post in the official PHP manual, but I&#8217;m going to list my experience with it along with <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.jtgraphic.net/2009/09/php-function-friday-function/">PHP Function Friday: function</a></span><p><a href="http://www.jtgraphic.net/2009/09/php-function-friday-function/">PHP Function Friday: function</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>
]]></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.jtgraphic.net%2F2009%2F09%2Fphp-function-friday-function%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F09%2Fphp-function-friday-function%2F&amp;source=jtgraphic&amp;style=normal&amp;service=bit.ly&amp;hashtags=date,function,Function+Friday,HTML,Link,PHP,Programming,return,strtotime,time,Tutorial" height="61" width="50" /><br />
			</a>
		</div>
<p>So, I&#8217;ve decided to start including a new post every Friday &#8211; kind of as a discipline thing.  I&#8217;m going to write a post on a PHP function every Friday.  I&#8217;m not just going to regurgitate the post in the official PHP manual, but I&#8217;m going to list my experience with it along with some creative ways to use it.</p>
<p>With out any further adieu, I&#8217;m posting on the first official building block (which isn&#8217;t technically a function, but I digress) &#8216;function&#8217;:</p>
<h3>PHP Function and Syntax</h3>
<pre>function <em>&lt;function name&gt;</em>(<em>&lt;parameters&gt;</em>) {
   /*add code here*/
}
</pre>
<h3>PHP Manual Entry</h3>
<p>Check here for version information, or anything I may have missed:</p>
<p><a href="http://www.php.net/manual/en/functions.user-defined.php" target="_blank">http://www.php.net/manual/en/functions.user-defined.php</a></p>
<h3>Notes and Use</h3>
<p>This is great for building blocks of code that you repeat a lot.  I like to use it when duplicating XML/HTML code, such as links or form elements, which I will outline below.  Functions, both custom and built in, are the primary building blocks of a good program.  Everything else is just procedural.</p>
<p>Also, on a side note: <a href="http://svn.php.net/viewvc/php/php-src/trunk/CODING_STANDARDS?view=co" target="_blank">PHP Coding Standards</a> is a good read if you&#8217;re really geeky.</p>
<p>An important thing to keep in mind about making custom functions is that someone has probably already made it if it doesn&#8217;t already exist in the built in functions for PHP.  Feel free to jump online and see if someone has already made a function to do what you&#8217;re trying to do.  I like to use the site <a href="http://www.hotscripts.com/" target="_blank">HotScripts.com</a>, which has both free and commercial PHP scripts available.  Chances are: if I need it, they have it.  It saves me a ton of time.</p>
<p>Note in the examples that I precede the function with some explanation of what it does, the author, etc.  This isn&#8217;t needed, but it&#8217;s a REALLY good habit.</p>
<h4>Other Functions Referenced in Examples</h4>
<ul>
<li><a href="http://php.net/manual/en/function.return.php" target="_blank">date()</a></li>
<li><a href="http://php.net/manual/en/function.return.php" target="_blank">strtotime()</a></li>
<li><a href="http://php.net/manual/en/function.return.php" target="_blank">time()</a></li>
<li><a href="http://php.net/manual/en/function.return.php" target="_blank">return()</a></li>
</ul>
<h3>Examples</h3>
<p>Here&#8217;s the meat.  Let&#8217;s make some stuff work.</p>
<h4>Creating Image Links</h4>
<pre>/*
 *  Author: James Thompson, jtGraphic.net
 *
 *  Description
 *  ------------------------------------
 *  This function is for displaying image links in HTML.  It's less typing,
 *  and easier to remember what needs to be slashed out.  An image
 *  with the same name as the file name of the page you're linking to needs to
 *  be placed on the server in the same path as the internal variable
 *  '$image_path' and the same extension as '$image_ext'.
 *
 *  Arguments
 *  ------------------------------------
 *  $url - URL of the link
 *  $extra_tag_html - this is any extra HTML, like class, id, or style
 *
 */

/* Build the function. */

	function create_html_link($name, $extra_tag_html) {
		/* Define internal variables. */
			$image_path = "images/";
			$image_ext   = ".jpg";

		/* Output the HTML. */
			echo
				"&lt;a href="\".$name.".php\" ".$extra_tag_html."&gt;
					&lt;img src=\"".$image_path.$name.$image_ext."\" /&gt;
				&lt;/a&gt;";
	}

/* Execute the function. */

	create_html_link("home", "class=\"normal_link\"");
	create_html_link("about", "class=\"normal_link\"");
	create_html_link("contact", "class=\"normal_link\"");
</pre>
<h4>Calculate the Number of Days Since Some other Date</h4>
<pre>/*
 *  Author: James Thompson, jtGraphic.net
 *
 *  Description
 *  ------------------------------------
 *  Simple.  This calculates the number of days since X date.
 *
 *  Arguments
 *  ------------------------------------
 *  $date - the date in this format: 'YYYY-MM-DD HH:MM:SS'
 *
 */

/* Build the function. */

	function num_days_since($date) {
		/* Do some time math. */
			$date = strtotime($date);
			$now = time();
			$difference = $now - $date;
			$days = $difference / 86400;

		/* Output the Value. */
			return $days;
	}

/* Execute the function. */

	/* Should return 0 */
		echo num_days_since(date("Y-m-d H:i:s"));
	/* Someone's birthday at 6:02:55AM on Oct 23, 1974 */
		echo num_days_since("1974-10-23 06:02:55");
	/* Since Jan 1, 2009 - no need for time */
		echo num_days_since("2009-01-01");
</pre>
<h3>Examples Elsewhere on this Site:</h3>
<p><a href="http://www.jtgraphic.net/2009/10/tidbit-tuesday-php-holiday-notices-business-sites/" target="_blank">Holiday Notices</a></p>
<h3>Conclusion</h3>
<p>So that&#8217;s the basics.  Functions can be very powerful in reducing the code on your websites.  If you&#8217;d like to see some more <a href="http://www.jtgraphic.net/tag/custom-functions/" target="_blank">custom functions</a>, check out my <a href="http://www.jtgraphic.net/tag/Tidbit-Tuesday/" target="_blank">Tidbit Tuesdays on PHP</a> If you have questions, let me know in the comments.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/10/php-function-friday-date/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="PHP Function Friday: date" title="PHP Function Friday: date" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/10/php-function-friday-date/" rel="bookmark" class="crp_title">PHP Function Friday: date</a><span class="crp_excerpt"> I think the date function is extremely useful.  It gives your programs an awareness of WHEN they are.  You can ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/10/php-function-friday-include/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="PHP Function Friday: include" title="PHP Function Friday: include" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/10/php-function-friday-include/" rel="bookmark" class="crp_title">PHP Function Friday: include</a><span class="crp_excerpt"> Including files makes it really easy to NOT duplicate code.  It's great for creating headers and footers for websites, ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/10/tidbit-tuesday-php-holiday-notices-business-sites/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="Tidbit Tuesday on PHP: Holiday Notices for Business Sites" title="Tidbit Tuesday on PHP: Holiday Notices for Business Sites" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/10/tidbit-tuesday-php-holiday-notices-business-sites/" rel="bookmark" class="crp_title">Tidbit Tuesday on PHP: Holiday Notices for Business Sites</a><span class="crp_excerpt"> This is a handy script for managing an out of office message on your website.  I find this very useful ...</span></li></ul></div><p><a href="http://www.jtgraphic.net/2009/09/php-function-friday-function/">PHP Function Friday: function</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F09%2Fphp-function-friday-function%2F&amp;title=PHP%20Function%20Friday%3A%20function&amp;bodytext=So%2C%20I%27ve%20decided%20to%20start%20including%20a%20new%20post%20every%20Friday%20-%20kind%20of%20as%20a%20discipline%20thing.%20%20I%27m%20going%20to%20write%20a%20post%20on%20a%20PHP%20function%20every%20Friday.%20%20I%27m%20not%20just%20going%20to%20regurgitate%20the%20post%20in%20the%20official%20PHP%20manual%2C%20but%20I%27m%20going%20to%20list%20my%20e" title="Digg"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F09%2Fphp-function-friday-function%2F&amp;title=PHP%20Function%20Friday%3A%20function&amp;notes=So%2C%20I%27ve%20decided%20to%20start%20including%20a%20new%20post%20every%20Friday%20-%20kind%20of%20as%20a%20discipline%20thing.%20%20I%27m%20going%20to%20write%20a%20post%20on%20a%20PHP%20function%20every%20Friday.%20%20I%27m%20not%20just%20going%20to%20regurgitate%20the%20post%20in%20the%20official%20PHP%20manual%2C%20but%20I%27m%20going%20to%20list%20my%20e" title="del.icio.us"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=facebook-post&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F09%2Fphp-function-friday-function%2F&d=http://www.facebook.com/share.php?u=TARGET%26t=PHP%20Function%20Friday%3A%20function" title="Facebook"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F09%2Fphp-function-friday-function%2F&amp;title=PHP%20Function%20Friday%3A%20function" title="Mixx"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F09%2Fphp-function-friday-function%2F&amp;title=PHP%20Function%20Friday%3A%20function&amp;annotation=So%2C%20I%27ve%20decided%20to%20start%20including%20a%20new%20post%20every%20Friday%20-%20kind%20of%20as%20a%20discipline%20thing.%20%20I%27m%20going%20to%20write%20a%20post%20on%20a%20PHP%20function%20every%20Friday.%20%20I%27m%20not%20just%20going%20to%20regurgitate%20the%20post%20in%20the%20official%20PHP%20manual%2C%20but%20I%27m%20going%20to%20list%20my%20e" title="Google Bookmarks"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F09%2Fphp-function-friday-function%2F&amp;title=PHP%20Function%20Friday%3A%20function" title="StumbleUpon"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F09%2Fphp-function-friday-function%2F" title="Technorati"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=myspace&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F09%2Fphp-function-friday-function%2F&d=http://www.myspace.com/Modules/PostTo/Pages/?u=TARGET%26t=PHP%20Function%20Friday%3A%20function" title="MySpace"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=twitter&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F09%2Fphp-function-friday-function%2F&d=http://twitter.com/home?status=PHP%20Function%20Friday%3A%20function%20-%20TARGET" title="Twitter"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F09%2Fphp-function-friday-function%2F" title="Sphinn"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F09%2Fphp-function-friday-function%2F&amp;title=PHP%20Function%20Friday%3A%20function" title="Reddit"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.jtgraphic.net/2009/09/php-function-friday-function/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Pathfinding in PHP</title>
		<link>http://www.jtgraphic.net/2009/08/pathfinding-php/</link>
		<comments>http://www.jtgraphic.net/2009/08/pathfinding-php/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 08:35:46 +0000</pubDate>
		<dc:creator>James Thompson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[pathfinding]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jtgraphic.net/?p=384</guid>
		<description><![CDATA[
			
				
			
		
<p>I&#8217;ve been playing around with doing some A* pathfinding scripts.  I was looking around on the web and didn&#8217;t find any anywhere, so I decided to make my own rudimentary one.  I&#8217;m going to be expounding on this later.  I thought about looking into the A* method and a few others.  Feel free to take the <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.jtgraphic.net/2009/08/pathfinding-php/">Pathfinding in PHP</a></span><p><a href="http://www.jtgraphic.net/2009/08/pathfinding-php/">Pathfinding in PHP</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>
]]></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.jtgraphic.net%2F2009%2F08%2Fpathfinding-php%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F08%2Fpathfinding-php%2F&amp;source=jtgraphic&amp;style=normal&amp;service=bit.ly&amp;hashtags=function,pathfinding,PHP,Programming" height="61" width="50" /><br />
			</a>
		</div>
<p>I&#8217;ve been playing around with doing some A* pathfinding scripts.  I was looking around on the web and didn&#8217;t find any anywhere, so I decided to make my own rudimentary one.  I&#8217;m going to be expounding on this later.  I thought about looking into the A* method and a few others.  Feel free to take the sample below.  <a href="http://www.jtgraphic.net/projects/pathfind.php" target="_blank">Here is a demo too</a>.</p>
<pre>&lt;style&gt;
 * {
 margin: 0px;
 padding: 0px;
 }
&lt;/style&gt;
&lt;body style="margin: 13px 0px 0px 0px; background: #000;"&gt;
&lt;?php
 /* Set the size of our target area */
 $range = 3;

 /* Build the pathfinding function */
 function pathfind($current_square_x, $current_square_y, $map, $steps, $target) {
 /* Give the function a step limit.  We don't want to create an endless loop. */
 $max_steps = 100;

 /* Define the next steps */
 $next_steps[$current_square_y + 1]    [$current_square_x + 1]    = "";
 $next_steps[$current_square_y + 1]    [$current_square_x]     = "";
 $next_steps[$current_square_y + 1]    [$current_square_x - 1]    = "";
 $next_steps[$current_square_y - 1]    [$current_square_x + 1]    = "";
 $next_steps[$current_square_y - 1]    [$current_square_x]        = "";
 $next_steps[$current_square_y - 1]    [$current_square_x - 1]    = "";
 $next_steps[$current_square_y]        [$current_square_x + 1]    = "";
 $next_steps[$current_square_y]        [$current_square_x - 1]    = "";

 /* Do some math to find the distance from here (as the crow flies) to the target) */
 $height = sizeof($map);
 $width = sizeof($map[0]);
 $minimum = sqrt(($width * $width) + ($height * $height));

 /* Find the closest tile */
 foreach($next_steps as $y_key =&gt; $y_value) {
 foreach($y_value as $x_key =&gt; $x_value) {
 if(
 isset($map[$y_key][$x_key]) &amp;&amp;
 $map[$y_key][$x_key] != "closed" &amp;&amp;
 $map[$y_key][$x_key] != "start" &amp;&amp;
 $steps &lt; $max_steps
 ) {
 if($map[$y_key][$x_key] != "traversed") {
 $width  = abs($x_key - $target['x']) + 1;
 $height = abs($y_key - $target['y']) + 1;
 $c = round(sqrt(($width * $width) + ($height * $height)),2);

 if($c &lt; $minimum) {
 $minimum = $c;
 $lowest_distance_position = $x_key."x".$y_key;
 }
 }
 }
 }
 }

 /* Start the next calculation from the closest tile */
 $position = explode("x",$lowest_distance_position);

 if(
 isset($map[$position[1]][$position[0]]) &amp;&amp;
 !($position[0] == $target['x'] &amp;&amp; $position[1] == $target['y'])
 ) {
 $map[$position[1]][$position[0]] = "traversed";

 $path[$position[0]."x".$position[1]] =
 pathfind($position[0], $position[1], $map, $steps + 1, $target);

 if($path) {
 return $path;
 break;
 }
 }

 return array($position[0]."x".$position[1] =&gt; "target");
 break;
 }

 /* Convert the three based array to a step based array. */
 function build_path($path_array, $step_number) {
 if(sizeof($path_array) &gt; 0 &amp;&amp; is_array($path_array)) {
 foreach($path_array as $key =&gt; $value) {
 $this_path[$step_number] = $key;

 if(sizeof($path_array[$key]) &gt; 0) {
 $built_path =
 array_merge(
 $this_path,
 build_path($path_array[$key], $step_number++)
 );
 return $built_path;
 }
 }
 } else {
 return array();
 }
 }

 /* Set the map size. */
 $map_size_x = 43;
 $map_size_y = 22;

 /* Build the blank map. */
 for($y = 0; $y &lt; $map_size_y; $y++) {
 for($x = 0; $x &lt; $map_size_x; $x++) {
 $map[$y][$x] = "open";
 }
 }

 /* Set special sections of the map. */
 $map[15][25] = "closed";
 $map[16][25] = "closed";
 $map[17][25] = "closed";
 $map[18][25] = "closed";
 $map[19][25] = "closed";
 $map[20][25] = "closed";
 $target['x'] = 39;
 $target['y'] = 18;
 $start['x'] = 1;
 $start['y'] = 1;

 $path = pathfind($start['x'], $start['y'], $map, 0, $target);
 $built_path = build_path($path, 1);

 /* Output the final map. */
 echo "&lt;table style=\"margin: 0px auto;\"&gt;";

 foreach($map as $y_key =&gt; $y_value) {
 echo "&lt;tr&gt;";

 foreach($y_value as $x_key =&gt; $x_value) {
 if($x_value == "closed") {
 $background = "F99";
 } elseif ($x_value == "path") {
 $background = "9F9";
 } elseif ($x_key == $start['x'] &amp;&amp; $y_key == $start['y']) {
 $background = "559";
 } elseif (
 $x_key &lt; $target['x'] + $range &amp;&amp;
 $x_key &gt; $target['x'] - $range &amp;&amp;
 $y_key &lt; $target['y'] + $range &amp;&amp;
 $y_key &gt; $target['y'] - $range
 ) {
 $background = "900";
 } elseif(in_array($x_key."x".$y_key,$built_path)) {
 $background = "353";
 } else {
 $background = "333";
 }

 echo
 "&lt;td
 style=\"
 background: #".$background.";
 width: 20px;
 height: 20px;
 text-align: center;
 \"&gt;
 &lt;/td&gt;";
 }

 echo "&lt;/tr&gt;";
 }

 echo "&lt;/table&gt;";
?&gt;
&lt;pre&gt;
 &lt;?php
 //print_r($path);
 ?&gt;
&lt;/pre&gt;
&lt;/body&gt;</pre>
<div id="crp_related"><h3>Related Posts:</h3><ul><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/09/php-function-friday-function/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="PHP Function Friday: function" title="PHP Function Friday: function" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/09/php-function-friday-function/" rel="bookmark" class="crp_title">PHP Function Friday: function</a><span class="crp_excerpt"> So, I've decided to start including a new post every Friday - kind of as a discipline thing.  I'm ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-insert-function/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="Tidbit Tuesday on PHP: Simple MySQL Database Insert Function" title="Tidbit Tuesday on PHP: Simple MySQL Database Insert Function" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-insert-function/" rel="bookmark" class="crp_title">Tidbit Tuesday on PHP: Simple MySQL Database Insert Function</a><span class="crp_excerpt"> This builds on a function I did last week: db_query().  You can send any array straight to a MySQL ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-query-function/" rel="bookmark"><img src="http://www.jtgraphic.net/wp-content/plugins/contextual-related-posts/default.png" alt="Tidbit Tuesday on PHP: Simple MySQL Database Query Function" title="Tidbit Tuesday on PHP: Simple MySQL Database Query Function" width="50" height="50" border="0" class="crp_thumb" /></a> <a href="http://www.jtgraphic.net/2009/11/tidbit-tuesday-php-simple-mysql-database-query-function/" rel="bookmark" class="crp_title">Tidbit Tuesday on PHP: Simple MySQL Database Query Function</a><span class="crp_excerpt"> It's always great to create functions for those things you do a lot.  Probably the single most common function I ...</span></li></ul></div><p><a href="http://www.jtgraphic.net/2009/08/pathfinding-php/">Pathfinding in PHP</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F08%2Fpathfinding-php%2F&amp;title=Pathfinding%20in%20PHP&amp;bodytext=I%27ve%20been%20playing%20around%20with%20doing%20some%20A%2A%20pathfinding%20scripts.%C2%A0%20I%20was%20looking%20around%20on%20the%20web%20and%20didn%27t%20find%20any%20anywhere%2C%20so%20I%20decided%20to%20make%20my%20own%20rudimentary%20one.%C2%A0%20I%27m%20going%20to%20be%20expounding%20on%20this%20later.%C2%A0%20I%20thought%20about%20looking%20into%20t" title="Digg"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F08%2Fpathfinding-php%2F&amp;title=Pathfinding%20in%20PHP&amp;notes=I%27ve%20been%20playing%20around%20with%20doing%20some%20A%2A%20pathfinding%20scripts.%C2%A0%20I%20was%20looking%20around%20on%20the%20web%20and%20didn%27t%20find%20any%20anywhere%2C%20so%20I%20decided%20to%20make%20my%20own%20rudimentary%20one.%C2%A0%20I%27m%20going%20to%20be%20expounding%20on%20this%20later.%C2%A0%20I%20thought%20about%20looking%20into%20t" title="del.icio.us"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=facebook-post&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F08%2Fpathfinding-php%2F&d=http://www.facebook.com/share.php?u=TARGET%26t=Pathfinding%20in%20PHP" title="Facebook"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F08%2Fpathfinding-php%2F&amp;title=Pathfinding%20in%20PHP" title="Mixx"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F08%2Fpathfinding-php%2F&amp;title=Pathfinding%20in%20PHP&amp;annotation=I%27ve%20been%20playing%20around%20with%20doing%20some%20A%2A%20pathfinding%20scripts.%C2%A0%20I%20was%20looking%20around%20on%20the%20web%20and%20didn%27t%20find%20any%20anywhere%2C%20so%20I%20decided%20to%20make%20my%20own%20rudimentary%20one.%C2%A0%20I%27m%20going%20to%20be%20expounding%20on%20this%20later.%C2%A0%20I%20thought%20about%20looking%20into%20t" title="Google Bookmarks"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F08%2Fpathfinding-php%2F&amp;title=Pathfinding%20in%20PHP" title="StumbleUpon"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F08%2Fpathfinding-php%2F" title="Technorati"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=myspace&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F08%2Fpathfinding-php%2F&d=http://www.myspace.com/Modules/PostTo/Pages/?u=TARGET%26t=Pathfinding%20in%20PHP" title="MySpace"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.jtgraphic.net/wp-content/plugins/sociable/awesmate.php?c=twitter&t=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F08%2Fpathfinding-php%2F&d=http://twitter.com/home?status=Pathfinding%20in%20PHP%20-%20TARGET" title="Twitter"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F08%2Fpathfinding-php%2F" title="Sphinn"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2009%2F08%2Fpathfinding-php%2F&amp;title=Pathfinding%20in%20PHP" title="Reddit"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.jtgraphic.net/2009/08/pathfinding-php/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
