<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<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/"
	>

<channel>
	<title>edrackham &#187; PHP</title>
	<link>http://edrackham.com</link>
	<description>PHP, MySQL, and Other Web Snippets!</description>
	<pubDate>Wed, 25 Jun 2008 13:38:14 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>Get Random Row with MySQL</title>
		<link>http://edrackham.com/php/get-random-row-with-mysql/</link>
		<comments>http://edrackham.com/php/get-random-row-with-mysql/#comments</comments>
		<pubDate>Sat, 09 Feb 2008 00:51:31 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[PHP]]></category>
<category>MySQL</category><category>PHP</category><category>Tutorial</category>
		<guid isPermaLink="false">http://edrackham.com/php/get-random-row-with-mysql/</guid>
		<description><![CDATA[UPDATE: Please see my newer atricle on how to retrieve a random row, faster, without RAND().






This post assumes you know how to create and use a connection to a MySQL database in PHP and have a table named &#039;quotes&#039; as shown below. In this post, I will aim to teach you how to use PHP [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE:</strong> Please see my newer atricle on <a href="http://edrackham.com/mysql/get-random-row-with-mysql-without-rand/" title="Blink, and you'll miss it!">how to retrieve a random row, faster, without RAND()</a>.</p>
<p>
<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
/* 468x60, created 3/10/08 */
google_ad_slot = "7234899452";
google_ad_width = 468;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</p>
<p>This post assumes you know how to create and use a connection to a MySQL database in PHP and have a table named &#039;quotes&#039; as shown below. In this post, I will aim to teach you how to use PHP to pull random quotes from a MYSQL table of quotes. This can be easily extended to pull a random banner as will be explained at the end of the post.</p>
<p>Let&#039;s firstly assume we have a MySQL table similar to the following:</p>
<pre>+----+------------------------------------------------+
| id | quote                                          |
+----+------------------------------------------------+
| 1  | I know Karate... and many other Chinese words! |
+----+------------------------------------------------+
| 2  | w00t this is geeky                             |
+----+------------------------------------------------+
| 3  | You're CLINICALLY MENTAL!                      |
+----+------------------------------------------------+</pre>
<p>
<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
/* 468x60, created 3/10/08 */
google_ad_slot = "7234899452";
google_ad_width = 468;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</p>
<p>Now, in your PHP code, we need to:</p>
<ol>
<li>Build a suitable MySQL query to obtain a random result from the &#039;quotes&#039; table.</li>
<li>Store the result of the query to be used in the HTML somewhere.</li>
<li>Output the result in the HTML somewhere.</li>
</ol>
<p>So, for step one we&#039;d use something like the following:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="re0">$sSQLQuery</span> = <span class="st0">&#034;SELECT quote FROM quotes ORDER BY RAND() LIMIT 1&#034;</span>;<br />
<span class="re0">$aResult</span> = <a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$sSQLQuery</span><span class="br0">&#41;</span>;<br />
<span class="re0">$aRow</span> = <a href="http://www.php.net/mysql_fetch_array"><span class="kw3">mysql_fetch_array</span></a><span class="br0">&#40;</span><span class="re0">$aResult</span>, MYSQL_ASSOC<span class="br0">&#41;</span>;<br />
<span class="re0">$sQuoteOfTheDay</span> = <span class="re0">$aRow</span><span class="br0">&#91;</span><span class="st0">&#039;quote&#039;</span><span class="br0">&#93;</span>;</div>
</div>
<p>There, the variable &#039;$sQuoteOfTheDay&#039; now has the value of our randomly pulled quote. Let&#039;s just analyse each line of the code above to see what it does.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="re0">$sSQLQuery</span> = <span class="st0">&#034;SELECT quote FROM quotes ORDER BY RAND() LIMIT 1&#034;</span>;</div>
</div>
<p>This line stores the MySQL query we&#039;re going to use against the database. It says, in laymans terms, &#034;Select just one random value of the quote field from the table named quotes&#034;. All this line does though is store the query into the variable &#039;$sSQLQuery&#039;.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="re0">$aResult</span> = <a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$sSQLQuery</span><span class="br0">&#41;</span>;</div>
</div>
<p>This line runs the MySQL query, storing the result of running the query in the variable &#039;$aResult&#039;. It&#039;s important that we store the result of the mysql_query in a variable, as the result of running a successful MySQL query using PHP&#039;s function &#039;mysql_query&#039; doesn’t return a nicely formatted array that we can necessarily use.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="re0">$aRow</span> = <a href="http://www.php.net/mysql_fetch_assoc"><span class="kw3">mysql_fetch_assoc</span></a><span class="br0">&#40;</span><span class="re0">$aResult</span><span class="br0">&#41;</span>;</div>
</div>
<p>This is probably the hardest line for me to explain. Firstly, many of you may have seen a similar line like this used in a &#039;while&#039; loop. However, our MySQL query used the &#039;LIMIT 1&#039; string, so we know we’re only going to get ONE result, hence no need for a loop. The function &#039;mysql_fetch_assoc&#039; takes one parameter: the result of the successful &#039;mysql_query&#039; which as we know is &#039;$aResult&#039;. My biggest tip here is to use the &#039;assoc&#039; method wherever possible, as it creates the array in such a way that we can reference each element by the column name, not a number. This is particularly useful if you ever update the MySQL table to have more columns.</p>
<p>Anyway, this line basically says &#039;Fill the variable &#039;$aRow&#039; with the CURRENT row of the returned query&#039;. We know that the CURRENT row of the returned query is the ONLY row, hence (again) the lack of a loop. As the result of our query would return something like:</p>
<pre>+-----------------------------------------------+
| quote                                         |
+-----------------------------------------------+
| You're CLINICALLY MENTAL!                     |
+-----------------------------------------------+</pre>
<p>
<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
/* 468x60, created 3/10/08 */
google_ad_slot = "7234899452";
google_ad_width = 468;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</p>
<p>Our variable (or array) would literally look something like:</p>
<div class="codesnip-container" >
<div class="codesnip"><a href="http://www.php.net/array"><span class="kw3">Array</span></a> <span class="br0">&#40;</span> <span class="st0">&#034;quote&#034;</span> = <span class="st0">&#034;You&#039;re CLINICALLY MENTAL!&#034;</span> <span class="br0">&#41;</span></div>
</div>
<p>Which leads us on to our last line:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="re0">$sQuoteOfTheDay</span> = <span class="re0">$aRow</span><span class="br0">&#91;</span><span class="st0">&#039;quote&#039;</span><span class="br0">&#93;</span>;</div>
</div>
<p>Which just assigns the value of &#039;$aRow[&#039;quote&#039;]&#039; to the variable &#039;$sQuoteOfTheDay&#039;. In other words, &#039;$sQuoteOfTheDay&#039; now has the value of a random quote pulled from the database of quotes.</p>
<p>To use this in an HTML page, we would simply just use this (AFTER the above code has grabbed the random quote from the DB for us):</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">&lt;?</span>= <span class="re0">$sQuoteOfTheDay</span>; <span class="kw2">?&gt;</span></div>
</div>
<p>Which will output the quote of the day somewhere in the HTML code.</p>
<p>As I said at the beginning, this can be extended easily to pull an image for a banner by simply changing the quotes table to store image paths such as &#039;images/my_image.png&#039; which can then be pulled in the same way, and then output similar to the following:</p>
<div class="codesnip-container" >
<div class="codesnip">&lt;img src=<span class="st0">&#034;&lt;?= $sImageOfTheDay; ?&gt;&#034;</span> alt=<span class="st0">&#034;My Image&#034;</span> /&gt;</div>
</div>
<p>Obviously we changed the variable name here to $sImageOfTheDay just to keep things constant.</p>
<p>Hope this has helped someone!</p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/php/get-random-row-with-mysql/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Class Tutorial</title>
		<link>http://edrackham.com/php/php-class-tutorial/</link>
		<comments>http://edrackham.com/php/php-class-tutorial/#comments</comments>
		<pubDate>Sat, 09 Feb 2008 00:39:09 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[PHP]]></category>
<category>Classes</category><category>PHP</category><category>Tutorial</category>
		<guid isPermaLink="false">http://edrackham.com/php/php-class-tutorial/</guid>
		<description><![CDATA[I’m not sure how to start this one… It can be quite difficult to understand PHP classes at first, but hopefully I’ll make everything seem easy! Let&#039;s just get stuck in shall we…
Brief overview…
Ok so you’re actually reading this brief overview? You must be serious…
PHP classes can be used to group together a set of [...]]]></description>
			<content:encoded><![CDATA[<p>I’m not sure how to start this one… It can be quite difficult to understand PHP classes at first, but hopefully I’ll make everything seem easy! Let&#039;s just get stuck in shall we…</p>
<h1>Brief overview…</h1>
<p>Ok so you’re actually reading this brief overview? You must be serious…</p>
<p>PHP classes can be used to group together a set of ‘like’ functions used within a bigger application. Their main advantage is the fact that you can edit the particular class function, or functions and make a site-wide change. Classes also help give you a more structured approach to programming, and those that like to hack with some GPL released web applications will have a much better understanding of the workings of them.</p>
<p>This may not be the best example of explaining why to use classes in PHP, but it’s an example of how to use them.</p>
<p>Let’s start by creating a new file called time.php. Within this file, let’s add some code:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">&lt;?php</span><br />
<span class="re0">$sTime</span> = <a href="http://www.php.net/gmdate"><span class="kw3">gmdate</span></a><span class="br0">&#40;</span><span class="st0">&#034;d-m-Y H:i:s&#034;</span><span class="br0">&#41;</span>;<br />
<a href="http://www.php.net/print"><span class="kw3">print</span></a> <span class="st0">&#039;The time is: &#039;</span> . <span class="re0">$sTime</span>;<br />
<span class="kw2">?&gt;</span></div>
</div>
<p>This will simply assign the current date and time to the variable <strong>$sTime</strong> and then print the string &#039;The time is&#039; with the variable value at the end (e.g. The time is: 09-02-2007 21:42:28)</p>
<p>How would we do this, using a class? Well there&#039;s many ways, however I would recommend using the class file to generate the time, then use the acutal &#039;action page&#039; (time.php) to output the time. Let&#039;s create our class file!</p>
<h1>Get in class!</h1>
<p>Create a new file (keep it in the same directory for this tutorial). Let’s call it <strong>class.Time.php</strong>. Add the following code:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">&lt;?php</span><br />
<span class="kw2">class</span> <a href="http://www.php.net/time"><span class="kw3">Time</span></a> <span class="br0">&#123;</span><br />
&nbsp; <span class="kw2">function</span> GenerateCurrentTime<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="re0">$sTime</span> = <a href="http://www.php.net/gmdate"><span class="kw3">gmdate</span></a><span class="br0">&#40;</span><span class="st0">&#034;d-m-Y H:i:s&#034;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$sTime</span>;<br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
<span class="kw2">?&gt;</span></div>
</div>
<p>Lets do this line by line… The first line, <strong>class Time {</strong>,declares the class as open (exactly the same as a function in PHP, but without the brackets in this case). The next line declares a new function. The difference here is that it exists ONLY within the scope of the class (e.g. it&#039;s built WITHIN the class). We then generate the time as we did before, assigning it to the variable $sTime and then return the value of this variable. The function then closes, followed by the class closure (the squiggly brackets &#039;}&#039;). Note that our class needs to also be wrapped in php tags (<?php … ?>).</p>
<p>Now open the original file, time.php, and change the code to match the following:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">&lt;?php</span><br />
<span class="kw1">include</span> <span class="br0">&#40;</span><span class="st0">&#039;class.Time.php&#039;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$oTime</span> = <span class="kw2">new</span> <a href="http://www.php.net/time"><span class="kw3">Time</span></a>;<br />
<span class="re0">$sTime</span> = <span class="re0">$oTime</span>-&gt;<span class="me1">GenerateCurrentTime</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<a href="http://www.php.net/print"><span class="kw3">print</span></a> <span class="st0">&#039;The time is: &#039;</span> . <span class="re0">$sTime</span>;<br />
<span class="kw2">?&gt;</span></div>
</div>
<p>Now, the first line here includes the time class file (<strong>include (&#039;class.Time.php&#039;);</strong>). We must include all the class files we wish to take advantage of, otherwise how the hell would PHP know about these files?</p>
<p>The next line, $oTime = new Time, creates the class object and stores it in the variable $oTime. Notice, to store the class in an object variable, we use <em>VARIABLE = NEW CLASSNAME</em>. <em>VARIABLE</em> can be anything, then there must be an equals sign &#039;=&#039;. <em>NEW </em>must use &#039;new&#039; or &#039;&#038;new&#039;, and the <em>CLASSNAME </em>must match the name of the class. In this case, the name of the class is Time (case sensitive - as PHP is throughout). The class name is &#039;Time&#039; because we created the class using <strong>class Time {</strong>.</p>
<p>If we had used <strong>class HelloWorld {</strong>, as you can guess, the class name would be &#039;HelloWorld&#039;.</p>
<p>Anyway… now we&#039;ve created our class, we have also included it within the page we want to make use of it. Not only that, we have ALSO initalised our class by defining it in an object variable - $oTime.</p>
<p>So, the next line:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="re0">$sTime</span> = <span class="re0">$oTime</span>-&gt;<span class="me1">GenerateCurrentTime</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</div>
<p>This simply assings the variable $sTime with the result of the function GenerateCurrentTime() within the Time class. How does it do this? Simple… We want to use the function GenerateCurrentTime() within the class $oTime so we simply us:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="re0">$oTime</span>-&gt;<span class="me1">GenerateCurrentTime</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</div>
<p>This tells PHP exactly what we want to do. The &#039;->&#039; explains to PHP that the prefix (in this case $oTime, which we know holds the class object) is the parent of the latter (again, in this case the latter is GenerateCurrentTime()). So it basically means, run GenerateCurrentTime() within the $oTime class. Thus assigning whatever is returned by the function GenerateCurrentTime() to the variable $sTime.</p>
<p>The last line does what we did from scratch… print out the results with the prefixed string &#039;The time is&#039;.</p>
<p>In the next installment, we will discuss what $this-> means, and how it can be immensly beneficial to you to use classes!</p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/php/php-class-tutorial/feed/</wfw:commentRss>
		</item>
		<item>
		<title>What Beautiful PHP &#038; AJAX Looks Like</title>
		<link>http://edrackham.com/php/what-beautiful-php-ajax-looks-like/</link>
		<comments>http://edrackham.com/php/what-beautiful-php-ajax-looks-like/#comments</comments>
		<pubDate>Tue, 13 Nov 2007 15:50:36 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[AJAX]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Beautiful]]></category>

		<category><![CDATA[Coding Standards]]></category>
<category>AJAX</category><category>Beautiful</category><category>Coding Standards</category><category>PHP</category>
		<guid isPermaLink="false">http://blog.edrackham.com/php/what-beautiful-php-ajax-looks-like/</guid>
		<description><![CDATA[I recently saw an image demonstrating What Beautiful HTML Looks Like. I&#039;ve decided to do my own What Beautiful PHP and AJAX Looks Like image. You can also play with the actual application that this image demonstrates if you so wish!

The Source
This example makes use of the Prototype JavaScript library. I&#039;m using this, as it [...]]]></description>
			<content:encoded><![CDATA[<p>I recently saw an image demonstrating <a href="http://www.ukimagehost.com/uploads/fff9652d04.jpg" title="It really is beautiful :]">What Beautiful HTML Looks Like</a>. I&#039;ve decided to do my own <a href="http://img251.imageshack.us/my.php?image=beautifulphpandajaxds5.jpg" title="This is mutually as beautiful!">What Beautiful PHP and AJAX Looks Like</a> image. You can also <a href="http://edrackham.com/tutorials/beautiful_php_and_ajax_tutorial/" title="If you're interested...">play with the actual application</a> that this image demonstrates if you so wish!</p>
<p><a target='_blank' href='http://img251.imageshack.us/my.php?image=beautifulphpandajaxds5.jpg' title='What Beautiful PHP and AJAX Looks Like'><img src='http://img251.imageshack.us/img251/4563/beautifulphpandajaxds5.th.jpg' border='0'/></a></p>
<h3><a href="http://edrackham.com/tutorials/beautiful_php_and_ajax_tutorial/source.php" title="View the source of this application">The Source</a></h3>
<p>This example makes use of the <a href="http://www.prototypejs.org/">Prototype JavaScript library</a>. I&#039;m using this, as it simplifies AJAX calls, and keeps this tutorial simple. You can <a href="http://edrackham.com/tutorials/beautiful_php_and_ajax_tutorial/source.php" title="Grab the source code of this application">view the full source here</a>, which you can view, copy and include in your AJAX applications. It contains suffice comments which should help you understand how everything works.</p>
<p>Credit for the email validation goes to <a href="http://www.ilovejackdaniels.com/php/email-address-validation/" title="I really DO love Jack Daniels!">ILoveJackDaniels</a>. It&#039;s not bullet-proof, but suffice for this example.</p>
<p>Comments would be much appreciated on this blog entry. Positive and constructive only.</p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/php/what-beautiful-php-ajax-looks-like/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Basic PHP Tutorial</title>
		<link>http://edrackham.com/php/basic-php-tutorial/</link>
		<comments>http://edrackham.com/php/basic-php-tutorial/#comments</comments>
		<pubDate>Mon, 05 Nov 2007 16:44:42 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[basics]]></category>

		<category><![CDATA[beginner]]></category>

		<guid isPermaLink="false">http://blog.edrackham.com/uncategorized/basic-php-tutorial/</guid>
		<description><![CDATA[Ok, so how do you load a .php file into your web browser, and what does it do when you type (for example) http://www.edrackham.com/index.php then hit enter?

The web browser requests the document with the .php extension from the edrackham.com server.
The webserver kicks in and says &#034;Hey! Someone wants a PHP file. Something else needs to [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, so how do you load a .php file into your web browser, and what does it do when you type (for example) http://www.edrackham.com/index.php then hit enter?</p>
<ol>
<li>The web browser requests the document with the .php extension from the edrackham.com server.</li>
<li>The webserver kicks in and says &#034;Hey! Someone wants a PHP file. Something else needs to deal with it because I only serve HTML&#034;, and then sends the request onto a PHP parser software located on the server.</li>
<li>The PHP parser finds the PHP file, then scans it for PHP code from top to bottom, left to right (how we read … that is if you&#039;re English).</li>
<li>When the PHP parser finds PHP code, it executes it and places the output (if any) into the place in the file formerly occupied by the code.</li>
<li>This new output is sent back to the webserver.</li>
<li>The webserver then sends it along to the web browser.</li>
<li>The web browser displays the output.</li>
</ol>
<p> <a href="http://edrackham.com/php/basic-php-tutorial/#more-5" class="more-link">(more&#8230;)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/php/basic-php-tutorial/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Get Days Between Two Dates Using PHP</title>
		<link>http://edrackham.com/php/get-days-between-two-dates-using-php/</link>
		<comments>http://edrackham.com/php/get-days-between-two-dates-using-php/#comments</comments>
		<pubDate>Thu, 01 Nov 2007 22:55:24 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Code]]></category>

		<category><![CDATA[Dates]]></category>
<category>Code</category><category>Dates</category><category>PHP</category>
		<guid isPermaLink="false">http://blog.edrackham.com/uncategorized/4/</guid>
		<description><![CDATA[This is a simple snippet of code that will return an array of days between two dates.
Read on for a little more info…
]]></description>
			<content:encoded><![CDATA[<p>This is a simple snippet of code that will return an array of days between two dates.</p>
<p>Read on for a little more info…</p>
<p> <a href="http://edrackham.com/php/get-days-between-two-dates-using-php/#more-4" class="more-link">(more&#8230;)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/php/get-days-between-two-dates-using-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Formatting dates in PHP</title>
		<link>http://edrackham.com/php/formatting-dates-in-php/</link>
		<comments>http://edrackham.com/php/formatting-dates-in-php/#comments</comments>
		<pubDate>Thu, 01 Nov 2007 21:56:57 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://blog.edrackham.com/?p=3</guid>
		<description><![CDATA[Ok, so how do you format dates in PHP so it outputs the date format you want? Well thanks to PHP’s date() and strtotime() function, we can do all that! To kick off, lets take the most common date format ‘YYYY-MM-DD HH:II:SS‘. This date format seems to be most favoured as it increments in such [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, so how do you <strong>format dates in PHP</strong> so it outputs the date format you want? Well thanks to PHP’s <a href="http://uk.php.net/date" title="PHP's date() function" target="_blank">date()</a> and <a href="http://uk2.php.net/strtotime" title="PHP's strtotime() function" target="_blank">strtotime()</a> function, we can do all that! To kick off, lets take the most common date format ‘<strong>YYYY-MM-DD HH:II:SS</strong>‘. This date format seems to be most favoured as it increments in such a way that allows you to query a database that has multiple records in a useful way, such as:</p>
<div class="codesnip-container" >
<div class="codesnip">SELECT * FROM dates WHERE <a href="http://www.php.net/date"><span class="kw3">date</span></a> &gt; <span class="st0">&#039;2006-03-05 11:00:00&#039;</span>;</div>
</div>
<p> <a href="http://edrackham.com/php/formatting-dates-in-php/#more-3" class="more-link">(more&#8230;)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/php/formatting-dates-in-php/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
