<?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; PHP</title>
	<atom:link href="http://www.jtgraphic.net/tag/php/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>What would you like to know?</title>
		<link>http://www.jtgraphic.net/2010/03/what-would-you-like-to-know/</link>
		<comments>http://www.jtgraphic.net/2010/03/what-would-you-like-to-know/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 00:14:09 +0000</pubDate>
		<dc:creator>James Thompson</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[websites]]></category>

		<guid isPermaLink="false">http://www.jtgraphic.net/?p=611</guid>
		<description><![CDATA[
			
				
			
		
<p>Have questions about making money online?  Building websites? PHP? Want to know something about me personally?  Ask me some questions below.  I&#8217;m talking about YOU.  Everyone should ask me a question.  Hit me up on Facebook or Twitter too.  I&#8217;m serious.  Ask as many questions as you want.  If I get a lot of the same <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.jtgraphic.net/2010/03/what-would-you-like-to-know/">What would you like to know?</a></span><p><a href="http://www.jtgraphic.net/2010/03/what-would-you-like-to-know/">What would you like to know?</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%2Fwhat-would-you-like-to-know%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Fwhat-would-you-like-to-know%2F&amp;source=jtgraphic&amp;style=normal&amp;service=bit.ly&amp;hashtags=Design,help,PHP,websites" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.jtgraphic.net/wp-content/question-mark.jpg"><img class="alignright size-medium wp-image-612" title="question-mark" src="http://www.jtgraphic.net/wp-content/question-mark-300x300.jpg" alt="" width="300" height="300" /></a>Have questions about making money online?  Building websites? PHP? Want to know something about me personally?  Ask me some questions below.  I&#8217;m talking about YOU.  Everyone should ask me a question.  Hit me up on Facebook or Twitter too.  I&#8217;m serious.  Ask as many questions as you want.  If I get a lot of the same questions, I&#8217;ll make a post about it.</p>
<p>There is no reason that you shouldn&#8217;t ask a question.  This post has no expiration date.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li style="clear: both;"><a href="http://www.jtgraphic.net/2010/07/series-52-weeks-successful-blog-week-3/" rel="bookmark"><img width="50" height="37" src="http://www.jtgraphic.net/wp-content/social_networking-300x224.jpg" class="crp_thumb wp-post-image" alt="Series: 52 Weeks to a Successful Blog: Week 3" title="Series: 52 Weeks to a Successful Blog: Week 3" border="0" /></a> <a href="http://www.jtgraphic.net/2010/07/series-52-weeks-successful-blog-week-3/" rel="bookmark" class="crp_title">Series: 52 Weeks to a Successful Blog: Week 3</a><span class="crp_excerpt"> Get social.
Now that you've laid the groundwork for your blog, it's time to get engaged.  You have great content and ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2010/06/review-money-online/" rel="bookmark"><img width="45" height="50" src="http://www.jtgraphic.net/wp-content/100_0257-270x300.jpg" class="crp_thumb wp-post-image" alt="Review: Make Money Online" title="Review: Make Money Online" border="0" /></a> <a href="http://www.jtgraphic.net/2010/06/review-money-online/" rel="bookmark" class="crp_title">Review: Make Money Online</a><span class="crp_excerpt"> "Make Money Online" by John Chow with Michael Kwan was an interesting book.  I've been doing the online marketing thing ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2010/07/series-52-weeks-successful-blog-week-1/" rel="bookmark"><img width="50" height="20" src="http://www.jtgraphic.net/wp-content/Picture-8-300x122.png" class="crp_thumb wp-post-image" alt="Series: 52 Weeks to a Successful Blog: Week 1" title="Series: 52 Weeks to a Successful Blog: Week 1" border="0" /></a> <a href="http://www.jtgraphic.net/2010/07/series-52-weeks-successful-blog-week-1/" rel="bookmark" class="crp_title">Series: 52 Weeks to a Successful Blog: Week 1</a><span class="crp_excerpt"> I'm starting a new blog series called 52 Weeks to Success.  It's going to be about starting a blog and ...</span></li></ul></div><p><a href="http://www.jtgraphic.net/2010/03/what-would-you-like-to-know/">What would you like to know?</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>



Share and Enjoy:


	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Fwhat-would-you-like-to-know%2F&amp;title=What%20would%20you%20like%20to%20know%3F&amp;bodytext=Have%20questions%20about%20making%20money%20online%3F%C2%A0%20Building%20websites%3F%20PHP%3F%20Want%20to%20know%20something%20about%20me%20personally%3F%C2%A0%20Ask%20me%20some%20questions%20below.%C2%A0%20I%27m%20talking%20about%20YOU.%C2%A0%20Everyone%20should%20ask%20me%20a%20question.%C2%A0%20Hit%20me%20up%20on%20Facebook%20or%20Twitter%20too.%C2%A0%20I%27m" title="Digg"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Fwhat-would-you-like-to-know%2F&amp;title=What%20would%20you%20like%20to%20know%3F&amp;notes=Have%20questions%20about%20making%20money%20online%3F%C2%A0%20Building%20websites%3F%20PHP%3F%20Want%20to%20know%20something%20about%20me%20personally%3F%C2%A0%20Ask%20me%20some%20questions%20below.%C2%A0%20I%27m%20talking%20about%20YOU.%C2%A0%20Everyone%20should%20ask%20me%20a%20question.%C2%A0%20Hit%20me%20up%20on%20Facebook%20or%20Twitter%20too.%C2%A0%20I%27m" 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>
	<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%2Fwhat-would-you-like-to-know%2F&d=http://www.facebook.com/share.php?u=TARGET%26t=What%20would%20you%20like%20to%20know%3F" title="Facebook"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Fwhat-would-you-like-to-know%2F&amp;title=What%20would%20you%20like%20to%20know%3F" title="Mixx"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Fwhat-would-you-like-to-know%2F&amp;title=What%20would%20you%20like%20to%20know%3F&amp;annotation=Have%20questions%20about%20making%20money%20online%3F%C2%A0%20Building%20websites%3F%20PHP%3F%20Want%20to%20know%20something%20about%20me%20personally%3F%C2%A0%20Ask%20me%20some%20questions%20below.%C2%A0%20I%27m%20talking%20about%20YOU.%C2%A0%20Everyone%20should%20ask%20me%20a%20question.%C2%A0%20Hit%20me%20up%20on%20Facebook%20or%20Twitter%20too.%C2%A0%20I%27m" title="Google Bookmarks"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Fwhat-would-you-like-to-know%2F&amp;title=What%20would%20you%20like%20to%20know%3F" title="StumbleUpon"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" /></a>
	<a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Fwhat-would-you-like-to-know%2F" title="Technorati"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" /></a>
	<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%2Fwhat-would-you-like-to-know%2F&d=http://www.myspace.com/Modules/PostTo/Pages/?u=TARGET%26t=What%20would%20you%20like%20to%20know%3F" title="MySpace"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" /></a>
	<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%2Fwhat-would-you-like-to-know%2F&d=http://twitter.com/home?status=What%20would%20you%20like%20to%20know%3F%20-%20TARGET" title="Twitter"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" /></a>
	<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%2Fwhat-would-you-like-to-know%2F" title="Sphinn"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Fwhat-would-you-like-to-know%2F&amp;title=What%20would%20you%20like%20to%20know%3F" title="Reddit"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.jtgraphic.net/2010/03/what-would-you-like-to-know/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Project BETA: New England Landmark Realty</title>
		<link>http://www.jtgraphic.net/2010/03/project-beta-england-landmark-realty/</link>
		<comments>http://www.jtgraphic.net/2010/03/project-beta-england-landmark-realty/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 06:23:53 +0000</pubDate>
		<dc:creator>James Thompson</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[New England Landmark Realty]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Sites]]></category>

		<guid isPermaLink="false">http://www.jtgraphic.net/?p=528</guid>
		<description><![CDATA[
			
				
			
		
<p class="wp-caption-text">New Website</p>
<p>I just finished the private beta for the New England Landmark Realty website.  Here it is:</p>
<p>New New England Landmark Realty Website</p>
<p>This will be going up at www.newenglandlandmarkrealty.com eventually, but not until after we get enough feedback.</p>
<p>Some of the new features include:</p>

 indexed and indexable MLS listings from both NNEREN and VREIN MLS IDX databases,
MUCH <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.jtgraphic.net/2010/03/project-beta-england-landmark-realty/">Project BETA: New England Landmark Realty</a></span><p><a href="http://www.jtgraphic.net/2010/03/project-beta-england-landmark-realty/">Project BETA: New England Landmark Realty</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%2Fproject-beta-england-landmark-realty%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Fproject-beta-england-landmark-realty%2F&amp;source=jtgraphic&amp;style=normal&amp;service=bit.ly&amp;hashtags=New+England+Landmark+Realty,PHP,Sites" height="61" width="50" /><br />
			</a>
		</div>
<div id="attachment_529" class="wp-caption alignright" style="width: 309px"><a href="http://www.jtgraphic.net/wp-content/Picture-10.png"><img class="size-medium wp-image-529" title="New England Landmark Realty" src="http://www.jtgraphic.net/wp-content/Picture-10-299x158.png" alt="" width="299" height="158" /></a><p class="wp-caption-text">New Website</p></div>
<p>I just finished the private beta for the New England Landmark Realty website.  Here it is:</p>
<p><a href="http://www.nelandmark.com" target="_blank">New New England Landmark Realty Website</a></p>
<p>This will be going up at <a href="http://www.newenglandlandmarkrealty" target="_blank">www.newenglandlandmarkrealty.com</a> eventually, but not until after we get enough feedback.</p>
<p>Some of the new features include:</p>
<ul>
<li> indexed and indexable MLS listings from both NNEREN and VREIN MLS IDX databases,</li>
<li>MUCH better SEO,</li>
<li>new design with slide show,</li>
<li>
<div id="attachment_530" class="wp-caption alignright" style="width: 310px"><a href="http://www.jtgraphic.net/wp-content/Picture-11.png"><img class="size-medium wp-image-530" title="New England Landmark Realty - Old" src="http://www.jtgraphic.net/wp-content/Picture-11-300x189.png" alt="" width="300" height="189" /></a><p class="wp-caption-text">Old Website</p></div>
<p>featured properties,</li>
<li>NELR property virtual tours and slide show movies,</li>
<li>back end analytics so they can actually see how the website is working.</li>
</ul>
<p>Anyways, head over there and let me know what you think in the comments below.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/11/vermont-quilt-festival/" rel="bookmark"><img width="50" height="50" src="http://www.jtgraphic.net/wp-content/Picture-3-150x150.png" class="crp_thumb wp-post-image" alt="Recent Project: Vermont Quilt Festival" title="Recent Project: Vermont Quilt Festival" border="0" /></a> <a href="http://www.jtgraphic.net/2009/11/vermont-quilt-festival/" rel="bookmark" class="crp_title">Recent Project: Vermont Quilt Festival</a><span class="crp_excerpt"> <div id="attachment_334" class="wp-caption alignright" style="width: 310px">[/caption]

We just finished a project for a local quilt ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2009/07/google-analytics-highlight-weekends/" rel="bookmark"><img width="50" height="8" src="http://www.jtgraphic.net/wp-content/Picture-9-300x49.jpg" class="crp_thumb wp-post-image" alt="Why can&#8217;t Google Analytics highlight weekends?" title="Why can&#8217;t Google Analytics highlight weekends?" border="0" /></a> <a href="http://www.jtgraphic.net/2009/07/google-analytics-highlight-weekends/" rel="bookmark" class="crp_title">Why can&#8217;t Google Analytics highlight weekends?</a><span class="crp_excerpt"> Wouldn't it be cool if you could highlight weekends in Google Analytics?  I could be missing something and it's possible, ...</span></li><li style="clear: both;"><a href="http://www.jtgraphic.net/2010/03/twit-live-slams-lady-hates-technology/" rel="bookmark"><img width="50" height="50" src="http://www.jtgraphic.net/wp-content/Picture-19-150x150.png" class="crp_thumb wp-post-image" alt="TWiT Live Slams a Lady That Hates Technology" title="TWiT Live Slams a Lady That Hates Technology" border="0" /></a> <a href="http://www.jtgraphic.net/2010/03/twit-live-slams-lady-hates-technology/" rel="bookmark" class="crp_title">TWiT Live Slams a Lady That Hates Technology</a><span class="crp_excerpt"> <div id="attachment_572" class="wp-caption alignright" style="width: 310px"><p class="wp-caption-text">@LisaTickledPink gets slammed with new followers.</p></div><p class="wp-caption-text">Front Page of the Vermont Quilt Festival Website</p></div>

I'm watching TWiT Live (http://live.twit.tv/).

@kevinrose did a search for "I hate ...</span></li></ul></div><p><a href="http://www.jtgraphic.net/2010/03/project-beta-england-landmark-realty/">Project BETA: New England Landmark Realty</a> is a post from: <a href="http://www.jtgraphic.net">jtGraphic: James Thompson</a></p>



Share and Enjoy:


	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Fproject-beta-england-landmark-realty%2F&amp;title=Project%20BETA%3A%20New%20England%20Landmark%20Realty&amp;bodytext=%0D%0A%0D%0AI%20just%20finished%20the%20private%20beta%20for%20the%20New%20England%20Landmark%20Realty%20website.%C2%A0%20Here%20it%20is%3A%0D%0A%0D%0ANew%20New%20England%20Landmark%20Realty%20Website%0D%0A%0D%0AThis%20will%20be%20going%20up%20at%20www.newenglandlandmarkrealty.com%20eventually%2C%20but%20not%20until%20after%20we%20get%20enough%20feed" title="Digg"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Fproject-beta-england-landmark-realty%2F&amp;title=Project%20BETA%3A%20New%20England%20Landmark%20Realty&amp;notes=%0D%0A%0D%0AI%20just%20finished%20the%20private%20beta%20for%20the%20New%20England%20Landmark%20Realty%20website.%C2%A0%20Here%20it%20is%3A%0D%0A%0D%0ANew%20New%20England%20Landmark%20Realty%20Website%0D%0A%0D%0AThis%20will%20be%20going%20up%20at%20www.newenglandlandmarkrealty.com%20eventually%2C%20but%20not%20until%20after%20we%20get%20enough%20feed" 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>
	<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%2Fproject-beta-england-landmark-realty%2F&d=http://www.facebook.com/share.php?u=TARGET%26t=Project%20BETA%3A%20New%20England%20Landmark%20Realty" title="Facebook"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Fproject-beta-england-landmark-realty%2F&amp;title=Project%20BETA%3A%20New%20England%20Landmark%20Realty" title="Mixx"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Fproject-beta-england-landmark-realty%2F&amp;title=Project%20BETA%3A%20New%20England%20Landmark%20Realty&amp;annotation=%0D%0A%0D%0AI%20just%20finished%20the%20private%20beta%20for%20the%20New%20England%20Landmark%20Realty%20website.%C2%A0%20Here%20it%20is%3A%0D%0A%0D%0ANew%20New%20England%20Landmark%20Realty%20Website%0D%0A%0D%0AThis%20will%20be%20going%20up%20at%20www.newenglandlandmarkrealty.com%20eventually%2C%20but%20not%20until%20after%20we%20get%20enough%20feed" title="Google Bookmarks"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Fproject-beta-england-landmark-realty%2F&amp;title=Project%20BETA%3A%20New%20England%20Landmark%20Realty" title="StumbleUpon"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" /></a>
	<a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Fproject-beta-england-landmark-realty%2F" title="Technorati"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" /></a>
	<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%2Fproject-beta-england-landmark-realty%2F&d=http://www.myspace.com/Modules/PostTo/Pages/?u=TARGET%26t=Project%20BETA%3A%20New%20England%20Landmark%20Realty" title="MySpace"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" /></a>
	<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%2Fproject-beta-england-landmark-realty%2F&d=http://twitter.com/home?status=Project%20BETA%3A%20New%20England%20Landmark%20Realty%20-%20TARGET" title="Twitter"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" /></a>
	<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%2Fproject-beta-england-landmark-realty%2F" title="Sphinn"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jtgraphic.net%2F2010%2F03%2Fproject-beta-england-landmark-realty%2F&amp;title=Project%20BETA%3A%20New%20England%20Landmark%20Realty" title="Reddit"><img src="http://www.jtgraphic.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.jtgraphic.net/2010/03/project-beta-england-landmark-realty/feed/</wfw:commentRss>
		<slash:comments>0</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>



Share and Enjoy:


	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>


<br/><br/>]]></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>



Share and Enjoy:


	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>


<br/><br/>]]></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>



Share and Enjoy:


	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>


<br/><br/>]]></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>



Share and Enjoy:


	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>


<br/><br/>]]></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: 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>



Share and Enjoy:


	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>


<br/><br/>]]></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>



Share and Enjoy:


	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>
	<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>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.jtgraphic.net/2009/08/pathfinding-php/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
