<?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</title>
	<link>http://edrackham.com</link>
	<description>PHP, MySQL, and Other Web Snippets!</description>
	<pubDate>Tue, 10 Feb 2009 14:52:47 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>Solution to Form Submit 403 Error</title>
		<link>http://edrackham.com/javascript/solution-to-form-submit-403-error/</link>
		<comments>http://edrackham.com/javascript/solution-to-form-submit-403-error/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 14:51:25 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[Form Submit 403]]></category>

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

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

		<guid isPermaLink="false">http://edrackham.com/javascript/solution-to-form-submit-403-error/</guid>
		<description><![CDATA[Have you ever had a problem where you get a HTTP 403 error from submitting a form?
Does this form have a field that submits a URL?
If yes to the above two questions, I think I know the problem you&#039;re having, and have a solution. It&#039;s to do with mod_security (an Apache module) and the &#039;http://&#039; [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever had a problem where you get a HTTP 403 error from submitting a form?<br />
Does this form have a field that submits a URL?</p>
<p>If <strong>yes</strong> to the above two questions, I think I know the problem you&#039;re having, and have a solution. It&#039;s to do with <a href="http://www.modsecurity.org/">mod_security</a> (an Apache module) and the &#039;http://&#039; part of the URL.</p>
<p> <a href="http://edrackham.com/javascript/solution-to-form-submit-403-error/#more-27" class="more-link">(more&#8230;)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/javascript/solution-to-form-submit-403-error/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Date Picker</title>
		<link>http://edrackham.com/php/php-date-picker/</link>
		<comments>http://edrackham.com/php/php-date-picker/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 13:38:18 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://edrackham.com/php/php-date-picker/</guid>
		<description><![CDATA[This is a simple to use script that can be called at anytime to insert a date picker into your form.
Example
Your browser does not support IFRAMES. Please view the date picker at http://edrackham.com/tutorials/php-date-picker/
Usage
Just make a call to

echo DatePicker&#40;&#41;;

 wherever you want the date picker to show. If you want to use it multiple times, just [...]]]></description>
			<content:encoded><![CDATA[<p>This is a simple to use script that can be called at anytime to insert a date picker into your form.</p>
<h3>Example</h3>
<p><iframe id="php_date_picker" name="php_date_picker" width="460" scrolling="no" height="70" frameborder="0" src="http://edrackham.com/tutorials/php-date-picker/?iframe">Your browser does not support IFRAMES. Please view the date picker at http://edrackham.com/tutorials/php-date-picker/</iframe></p>
<h3>Usage</h3>
<p>Just make a call to
<div class="codesnip-container" >
<div class="codesnip"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> DatePicker<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</div>
<p> wherever you want the date picker to show. If you want to use it multiple times, just call it multiple times like
<div class="codesnip-container" >
<div class="codesnip"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> DatePicker<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> DatePicker<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</div>
<p> but make sure you have the first line of the code un commented.</p>
<h3>The Code</h3>
<div class="codesnip-container" >
<div class="codesnip"><span class="re0">$iDatePickerCounter</span> = <span class="st0">&#034;</span>;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// Used for having multiple date pickers</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// comment it out if you&#039;re only going to</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// use ONE datepicker call on this page.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// (It&#039;ll make the form element names</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// nicer to work with).</span><br />
<span class="re0">$sYearName</span> &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;= <span class="st0">&#039;Year&#039;</span>;&nbsp; &nbsp; <span class="co1">// Base name for the Year form element</span><br />
<span class="re0">$sMonthName</span> &nbsp; &nbsp; &nbsp; &nbsp; = <span class="st0">&#039;Month&#039;</span>;&nbsp; <span class="co1">// Base name for the Month form element</span><br />
<span class="re0">$sDayName</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = <span class="st0">&#039;Day&#039;</span>;&nbsp; &nbsp; &nbsp; <span class="co1">// Base name for the Day form element</span></p>
<p><span class="re0">$iFromYear</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = <span class="nu0">1985</span>;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// Starting Year</span><br />
<span class="re0">$iToYear</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = <span class="nu0">2030</span>;&nbsp;&nbsp;<span class="co1">// Ending Year</span></p>
<p><span class="kw2">function</span> DatePicker<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Call up the global variables</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/global"><span class="kw3">global</span></a> <span class="re0">$iDatePickerCounter</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span class="re0">$sYearName</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span class="re0">$sMonthName</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span class="re0">$sDayName</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span class="re0">$iFromYear</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span class="re0">$iToYear</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Set up some base variables</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sPostFix</span> = <span class="st0">&#034;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sNL</span> = <span class="st0">&#034;<span class="es0">\r</span><span class="es0">\n</span>&#034;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// If we&#039;re using the counter (for more than one</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// date picker), increment the counter and create</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// the postfix string.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$iDatePickerCounter</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$iDatePickerCounter</span>++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sPostFix</span> = <span class="st0">&#039;_&#039;</span> . <span class="re0">$iDatePickerCounter</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Start the coding of the SELECT areas</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sYearDropDown</span> &nbsp;= <span class="st0">&#039;&lt;select name=&quot;&#039;</span> . <span class="re0">$sYearName</span> . <span class="re0">$sPostFix</span> . <span class="st0">&#039;&quot; id=&quot;&#039;</span> . <span class="re0">$sYearName</span> . <span class="re0">$sPostFix</span> . <span class="st0">&#039;&quot;&gt;&#039;</span> . <span class="re0">$sNL</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sMonthDropDown</span> = <span class="st0">&#039;&lt;select name=&quot;&#039;</span> . <span class="re0">$sMonthName</span> . <span class="re0">$sPostFix</span> . <span class="st0">&#039;&quot; id=&quot;&#039;</span> . <span class="re0">$sMonthName</span> . <span class="re0">$sPostFix</span> . <span class="st0">&#039;&quot;&gt;&#039;</span> . <span class="re0">$sNL</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sDayDropDown</span> &nbsp; = <span class="st0">&#039;&lt;select name=&quot;&#039;</span> . <span class="re0">$sDayName</span> . <span class="re0">$sPostFix</span> . <span class="st0">&#039;&quot; id=&quot;&#039;</span> . <span class="re0">$sDayName</span> . <span class="re0">$sPostFix</span> . <span class="st0">&#039;&quot;&gt;&#039;</span> . <span class="re0">$sNL</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Year loop</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span><span class="br0">&#40;</span><span class="re0">$i</span> = <span class="re0">$iFromYear</span>; <span class="re0">$i</span> &lt;= <span class="re0">$iToYear</span>; <span class="re0">$i</span>++<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sYearDropDown</span> .= <span class="st0">&#034;<span class="es0">\t</span>&#034;</span> . <span class="st0">&#039;&lt;option value=&quot;&#039;</span> . <span class="re0">$i</span> . <span class="st0">&#039;&quot;&#039;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Here we&#039;re checking if a POST or GET variable with</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// the same name as this SELECT element is set. If it</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// is, then we&#039;re going to see if the values of the </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// SELECT element (in this iteration) matches the </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// value of the request element. If it does, well set</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// this option as selected by default.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sYearDropDown</span> .= <span class="br0">&#40;</span><a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$_REQUEST</span><span class="br0">&#91;</span><span class="re0">$sYearName</span> . <span class="re0">$sPostFix</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> ? <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;<span class="br0">&#40;</span><span class="br0">&#40;</span><span class="re0">$_REQUEST</span><span class="br0">&#91;</span><span class="re0">$sYearName</span> . <span class="re0">$sPostFix</span><span class="br0">&#93;</span> == <span class="re0">$i</span><span class="br0">&#41;</span> ? <span class="st0">&#039; selected=&quot;selected&quot;&#039;</span> : <span class="st0">&#034;</span><span class="br0">&#41;</span> :<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;<span class="st0">&#034;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sYearDropDown</span> .= <span class="st0">&#039;&gt;&#039;</span> . <span class="re0">$i</span> . <span class="st0">&#039;&lt;/option&gt;&#039;</span> . <span class="re0">$sNL</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sYearDropDown</span> .= <span class="st0">&#039;&lt;/select&gt;&#039;</span> . <span class="re0">$sNL</span> . <span class="re0">$sNL</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Month Loop</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sDummyDate</span> = <span class="st0">&#039;2008-01-01&#039;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span><span class="br0">&#40;</span><span class="re0">$i</span> = <span class="nu0">0</span>; <span class="re0">$i</span> &lt; <span class="nu0">12</span>; <span class="re0">$i</span>++<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sMonthDropDown</span> .= <span class="st0">&#034;<span class="es0">\t</span>&#034;</span> .<span class="st0">&#039;&lt;option value=&quot;&#039;</span> . <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&#039;m&#039;</span>, <a href="http://www.php.net/strtotime"><span class="kw3">strtotime</span></a><span class="br0">&#40;</span><span class="st0">&#039;+&#039;</span> . <span class="re0">$i</span> . <span class="st0">&#039; months&#039;</span>, <a href="http://www.php.net/strtotime"><span class="kw3">strtotime</span></a><span class="br0">&#40;</span><span class="re0">$sDummyDate</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> . <span class="st0">&#039;&quot;&#039;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Here we&#039;re checking if a POST or GET variable with</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// the same name as this SELECT element is set. If it</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// is, then we&#039;re going to see if the values of the </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// SELECT element (in this iteration) matches the </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// value of the request element. If it does, well set</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// this option as selected by default.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sMonthDropDown</span> .= <span class="br0">&#40;</span><a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$_REQUEST</span><span class="br0">&#91;</span><span class="re0">$sMonthName</span> . <span class="re0">$sPostFix</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> ? <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;<span class="br0">&#40;</span><span class="br0">&#40;</span><span class="re0">$_REQUEST</span><span class="br0">&#91;</span><span class="re0">$sMonthName</span> . <span class="re0">$sPostFix</span><span class="br0">&#93;</span> == <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&#039;m&#039;</span>, <a href="http://www.php.net/strtotime"><span class="kw3">strtotime</span></a><span class="br0">&#40;</span><span class="st0">&#039;+&#039;</span> . <span class="re0">$i</span> . <span class="st0">&#039; months&#039;</span>, <a href="http://www.php.net/strtotime"><span class="kw3">strtotime</span></a><span class="br0">&#40;</span><span class="re0">$sDummyDate</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> ? <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;<span class="st0">&#039; selected=&quot;selected&quot;&#039;</span> : <span class="st0">&#034;</span><span class="br0">&#41;</span> : <span class="st0">&#034;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sMonthDropDown</span> .= <span class="st0">&#039;&gt;&#039;</span> . <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&#039;M&#039;</span>, <a href="http://www.php.net/strtotime"><span class="kw3">strtotime</span></a><span class="br0">&#40;</span><span class="st0">&#039;+&#039;</span> . <span class="re0">$i</span> . <span class="st0">&#039; months&#039;</span>, <a href="http://www.php.net/strtotime"><span class="kw3">strtotime</span></a><span class="br0">&#40;</span><span class="re0">$sDummyDate</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> . <span class="st0">&#039;&lt;/option&gt;&#039;</span> . <span class="re0">$sNL</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sMonthDropDown</span> .= <span class="st0">&#039;&lt;/select&gt;&#039;</span> . <span class="re0">$sNL</span> . <span class="re0">$sNL</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Day loop</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span><span class="br0">&#40;</span><span class="re0">$i</span> = <span class="nu0">1</span>; <span class="re0">$i</span> &lt;= <span class="nu0">31</span>; <span class="re0">$i</span>++<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sDayDropDown</span> .= <span class="st0">&#034;<span class="es0">\t</span>&#034;</span> .<span class="st0">&#039;&lt;option value=&quot;&#039;</span> . <span class="re0">$i</span> . <span class="st0">&#039;&quot;&#039;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Here we&#039;re checking if a POST or GET variable with</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// the same name as this SELECT element is set. If it</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// is, then we&#039;re going to see if the values of the </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// SELECT element (in this iteration) matches the </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// value of the request element. If it does, well set</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// this option as selected by default.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sDayDropDown</span> .= <span class="br0">&#40;</span><a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$_REQUEST</span><span class="br0">&#91;</span><span class="re0">$sDayName</span> . <span class="re0">$sPostFix</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> ? <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class="br0">&#40;</span><span class="br0">&#40;</span><span class="re0">$_REQUEST</span><span class="br0">&#91;</span><span class="re0">$sDayName</span> . <span class="re0">$sPostFix</span><span class="br0">&#93;</span> == <span class="re0">$i</span><span class="br0">&#41;</span> ? <span class="st0">&#039; selected=&quot;selected&quot;&#039;</span> : <span class="st0">&#034;</span><span class="br0">&#41;</span> :<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class="st0">&#034;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sDayDropDown</span> .= <span class="st0">&#039;&gt;&#039;</span> . <span class="re0">$i</span> . <span class="st0">&#039;&lt;/option&gt;&#039;</span> . <span class="re0">$sNL</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sDayDropDown</span> .= <span class="st0">&#039;&lt;/select&gt;&#039;</span> . <span class="re0">$sNL</span> . <span class="re0">$sNL</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Return all three dropdowns <img src='http://edrackham.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$sYearDropDown</span> . <span class="re0">$sMonthDropDown</span> . <span class="re0">$sDayDropDown</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<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>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/php/php-date-picker/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Functions Inc.</title>
		<link>http://edrackham.com/tools/functions-inc/</link>
		<comments>http://edrackham.com/tools/functions-inc/#comments</comments>
		<pubDate>Sun, 04 Jan 2009 21:12:17 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://edrackham.com/featured/functions-inc/</guid>
		<description><![CDATA[Functions Inc. is a new site I&#039;ve started for all you guys to add your code snippets to. It&#039;s an online code snippet repository where you can add your useful snippets, as well as view others. You can keep your snippets private, just using the site as an online code library, or choose to share [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://functionsinc.com">Functions Inc.</a> is a new site I&#039;ve started for all you guys to add your code snippets to. It&#039;s an online code snippet repository where you can add your useful snippets, as well as view others. You can keep your snippets private, just using the site as an online code library, or choose to share them with others.</p>
<p>Why not <a href="http://functionsinc.com">head over there now</a> and check it out. It&#039;s free!</p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/tools/functions-inc/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Awesome Form Validation</title>
		<link>http://edrackham.com/uncategorized/awesome-form-validation/</link>
		<comments>http://edrackham.com/uncategorized/awesome-form-validation/#comments</comments>
		<pubDate>Wed, 25 Jun 2008 13:33:00 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://edrackham.com/uncategorized/awesome-form-validation/</guid>
		<description><![CDATA[I don&#039;t know about you, but I always work hard on my form validation (and would never use just JUST JavaScript to validate input locally). It puts a smile on my face when a form is technically valid, yet won&#039;t submit:

]]></description>
			<content:encoded><![CDATA[<p>I don&#039;t know about you, but I always work hard on my form validation (and would never use just JUST JavaScript to validate input locally). It puts a smile on my face when a form is technically valid, yet won&#039;t submit:</p>
<p><img src="http://edrackham.com/images/posts/awesome-form-validation.jpg" alt="Awesome Form Validation" /></p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/uncategorized/awesome-form-validation/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Simple Web 2.0 Design and CSS Tutorial</title>
		<link>http://edrackham.com/css/simple-web-20-design-and-css-tutorial/</link>
		<comments>http://edrackham.com/css/simple-web-20-design-and-css-tutorial/#comments</comments>
		<pubDate>Mon, 17 Mar 2008 16:37:28 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[CSS]]></category>

		<category><![CDATA[Photoshop]]></category>
<category>css</category><category>layout</category><category>photoshop</category><category>Tutorial</category><category>web2.0</category><category>xhtml</category>
		<guid isPermaLink="false">http://edrackham.com/css/simple-web-20-design-and-css-tutorial/</guid>
		<description><![CDATA[This tutorial aims at teaching you how to make a simple &#034;Web 2.0&#034; design.


Setup
To start, let&#039;s create a new document in Photoshop, 1024px (width) by 700px (height).


Guides
Now, lets set up predefined areas (for areas like the header, and content) using guides. We will be creating four guides for now.



First Guide: Horizontal, position: 160px
Second Guide: Horizontal, [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial aims at teaching you how to make a simple &#034;Web 2.0&#034; design.</p>
<p><a href='http://www.mediafire.com/?m1umgjhexzv' title="Download all the files used in this tutorial"><img src="http://edrackham.com/images/download_tut_files.png" alt="Download Tutorial Files" border="0" /></a></p>
<p><a href="http://www.edrackham.com/tutorials/simple-web20-layout-in-photoshop/" title="My final design"><img src="http://edrackham.com/images/view_it.png" alt="View Final Design" border="0" /></a></p>
<h3>Setup</h3>
<p>To start, let&#039;s create a new document in Photoshop, 1024px (width) by 700px (height).</p>
<p><a href="http://imgplace.com/image/view/035e6910e639bb75b011705577421ed9" target="_blank" title="View Larger Image"><img src="http://imgplace.com/image_bin/2510/035e6910e639bb75b011705577421ed9.png.th.jpg" border="0" alt="Document Setup"></a></p>
<div style="clear: both;"></div>
<h3>Guides</h3>
<p>Now, lets set up predefined areas (for areas like the header, and content) using guides. We will be creating four guides for now.</p>
<p><a href="http://imgplace.com/image/view/7b82fc1da823cdc0474ac72b18234e98" target="_blank" title="View Larger Image"><img src="http://imgplace.com/image_bin/3291/7b82fc1da823cdc0474ac72b18234e98.png.th.jpg" border="0" alt="Creating New Guides"></a></p>
<div style="clear: both;"></div>
<ul>
<li><strong>First Guide:</strong> Horizontal, position: 160px</li>
<li><strong>Second Guide:</strong> Horizontal, position: 620px</li>
<li><strong>Third Guide:</strong> Vertical, position: 62px</li>
<li><strong>Fourth Guide:</strong> Vertical, position: 962px</li>
</ul>
<p>You should now have something that resembles the following (ignore the fact that there&#039;s the BG coloured in there, that wasn&#039;t supposed to be there just yet):</p>
<p><a href="http://imgplace.com/image/view/8427781b4c9e2dbb44c11cd24a058a85" target="_blank" title="View Larger Image"><img src="http://imgplace.com/image_bin/4841/8427781b4c9e2dbb44c11cd24a058a85.png.th.jpg" border="0" alt="Our Guides"></a></p>
<div style="clear: both;"></div>
<h3>Background</h3>
<p>&#034;Web 2.0&#034; seems to be all about gradients, so choose a foreground and background colour. I used foreground: #6d6657 and background: #302a1d. Use the gradient tool, then click at the top of the document, and drag down to the first horizontal guide (160px down). You should have something like the following:</p>
<p><a href="http://imgplace.com/image/view/ce7986f13ebd89efe64d6cad3adf9ad5" target="_blank" title="View Larger Image"><img src="http://imgplace.com/image_bin/8870/ce7986f13ebd89efe64d6cad3adf9ad5.png.th.jpg" border="0" alt="Background"></a></p>
<div style="clear: both;"></div>
<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>
<h3>Content Area</h3>
<p>Choose the rounded rectangle tool, and set a corner radius of 10px. Now make sure that your window is expanded a little more than the actual document size so that you can begin to draw your content area just outside the top of the document. Start about 15px above the document, and at the first vertical guide (62px in). Drag out a rounded rectangle down to the bottom horizontal guide, and aligned with the right hand vertical guide (962px in). You should see the following:</p>
<p><a href="http://imgplace.com/image/view/124c5d9ec60354b9d440c5243440910b" target="_blank" title="View Larger Image"><img src="http://imgplace.com/image_bin/5796/124c5d9ec60354b9d440c5243440910b.png.th.jpg" border="0" alt="Content Background"></a></p>
<div style="clear: both;"></div>
<p>Now, add the following layer style to the rounded rectangle:</p>
<p><a href="http://imgplace.com/image/view/b16464d0997d72b4d8342e82f512a7d3" target="_blank" title="View Larger Image"><img src="http://imgplace.com/image_bin/9182/b16464d0997d72b4d8342e82f512a7d3.png.th.jpg" border="0" alt="Content Area Style"></a></p>
<div style="clear: both;"></div>
<h3>Header</h3>
<p>Now lets set up the header. Create a new layer and use the Rectangular Marquee Tool and draw from the top left of the document all the way to the right, and down to the first horizontal guide. Fill with a colour of your choice. If you&#039;re following this guide, I used #918977. Change the blend mode to &#039;Darker Color&#039; and add a drop shadow using the following settings:</p>
<p><a href="http://imgplace.com/image/view/8c4fb525fdd13ba1fc957d37866370d1" target="_blank" title="View Larger Image"><img src="http://imgplace.com/image_bin/9816/8c4fb525fdd13ba1fc957d37866370d1.png.th.jpg" border="0" alt="Header Style"></a></p>
<div style="clear: both;"></div>
<p>Now grab a decent pattern, there are some nice ones at <a href="http://squidfingers.com/patterns/" title="Lots of nice patterns">SquidFingers</a>. Choose one, open it in photoshop and <a href="http://www.hongkiat.com/blog/creating-custom-pattern-in-photoshop/" title="How to define a pattern in Photoshop">define it as a pattern</a> (steps 1 &#038; 2 only). <strong>IMPORTANT:</strong> Remember the width of the image. Mine is 34px. Once you have your pattern defined, bring up the main layout document we&#039;re working on and Ctrl+Click on the image part of the header layer in the layers panel. This should have selected the header section. Create a new layer above and choose Edit > Fill. Select your newly defined pattern, and fill this header area.</p>
<p>Now, set the Blending Mode to Luminosity, and press Q to enter Quick Mask mode. In Quick Mask mode, with the new layer selected (with the nice pattern on it) - choose the Gradient tool.</p>
<p><a href="http://imgplace.com/image/view/8b361b64c9ea67fe133a29e275a3a877" target="_blank" title="View Larger Image"><img src="http://imgplace.com/image_bin/5965/8b361b64c9ea67fe133a29e275a3a877.png.th.jpg" border="0" alt="Gradient Tool"></a></p>
<div style="clear: both;"></div>
<p>Drag a gradient from the top of the screen, down to the first horizontal guide (160px down). You&#039;ll have a red gradient, don&#039;t worry about that - we&#039;re in Quick Mask mode and it&#039;s supposed to do that. Now press Q to exit the Quick Mask mode, then press delete. Your pattern should now fade out as it gets closer to the bottom of the header section:</p>
<p><a href="http://imgplace.com/image/view/49e0b218929927ad5cb24462db3d9353" target="_blank" title="View Larger Image"><img src="http://imgplace.com/image_bin/7833/49e0b218929927ad5cb24462db3d9353.png.th.jpg" border="0" alt="Gradient Header"></a></p>
<div style="clear: both;"></div>
<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>
<h3>Saving your Slices</h3>
<p>That&#039;s your layout basically done (without any content / images). Now to save the slices for our XHTML layout. Create two new horizontal guides, the first one set with a position of 170px, and the second with a position of 610px. Now, use the slice tool, and create a slice from the top left, across the entire width, and down to the first new horizontal guide (170px down). Create a second slice starting from the left and down at 170px, drag it all the way to the right and down to the second new horizontal guide. Create a third slice with the remaining space. You should have the following:</p>
<p><a href="http://imgplace.com/image/view/5bc07cb2e1a5055daf11726abcea4df3" target="_blank" title="View Larger Image"><img src="http://imgplace.com/image_bin/6039/5bc07cb2e1a5055daf11726abcea4df3.png.th.jpg" border="0" alt="Saving Slices"></a></p>
<div style="clear: both;"></div>
<p>Now choose &#039;File > Save for Web &#038; Devices&#039; and save the images. This process will create a folder in your directory you chose to save them in. Within this folder will be your three sliced images. Browse to that folder, and delete the middle image. We don&#039;t need this. Name the header slice &#039;header&#039; and the footer image &#039;footer&#039;. Move both the header and footer images to your web image directory.</p>
<p>Now, back in photoshop, using the Rectangular Marquee tool select from the top left, all the way to the bottom and go in the number of pixels that match the width of your pattern you used earlier from the left edge of the document. Goto Edit > Copy Merged, then click File > New Document and make sure the dimensions are <<em>width of pattern</em>>px by 700px. Paste in the copied image, then File > Save for Web &#038; Devices. Save this image as &#039;main_bg&#039;. This is your main background image. Now, choose the Single Row Marquee Tool, and click once in the middle section of your main document (anywhere that the second slice contains). Do the same as before with the vertical slice&#8230; copy merged, open a new document, paste it in and save for web as &#039;content_bg&#039;.</p>
<p>You should now have 4 main images:</p>
<ul>
<li>header</li>
<li>footer</li>
<li>main_bg</li>
<li>content_bg</li>
</ul>
<h3>Creating the XHTML / CSS</h3>
<p>Firstly, lets set up our directory structure. We will be needing the following:</p>
<ul>
<li>index.html</li>
<li>design.css</li>
<li>folder for images</li>
</ul>
<p>We will be wanting a final directory structure that resembles the following:</p>
<pre>+-my layout/
  |
  +-img/
  | |
  | +- content_bg.png
  | +- footer.png
  | +- header.png
  | +- main_bg.png
  |
  +- design.css
  +- index.html</pre>
<p>Navigate to your root folder for this tutorial (where the files are going to be saved). Create a new folder called <strong>img</strong> and copy your images into it.</p>
<p>Now create the XHTML document (<strong>index.html</strong>). Let&#039;s use the following Dreamweaver default as a nice structure to work from:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="sc0">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span><br />
<span class="sc2"><a href="http://december.com/html/4/element/html.html"><span class="kw2">&lt;html</span></a> xmlns=<span class="st0">&#034;http://www.w3.org/1999/xhtml&#034;</span><span class="kw2">&gt;</span></a></span><br />
<span class="sc2"><a href="http://december.com/html/4/element/head.html"><span class="kw2">&lt;head&gt;</span></a></span><br />
<span class="sc2"><a href="http://december.com/html/4/element/meta.html"><span class="kw2">&lt;meta</span></a> <span class="kw3">http-equiv</span>=<span class="st0">&#034;Content-Type&#034;</span> <span class="kw3">content</span>=<span class="st0">&#034;text/html; charset=utf-8&#034;</span> /<span class="kw2">&gt;</span></a></span><br />
<span class="sc2"><a href="http://december.com/html/4/element/title.html"><span class="kw2">&lt;title&gt;</span></a></span>My Web2.0 Layout<span class="sc2"><span class="kw2">&lt;/title&gt;</span></span><br />
<span class="sc2"><span class="kw2">&lt;/head&gt;</span></span></p>
<p><span class="sc2"><a href="http://december.com/html/4/element/body.html"><span class="kw2">&lt;body&gt;</span></a></span><br />
<span class="sc2"><span class="kw2">&lt;/body&gt;</span></span><br />
<span class="sc2"><span class="kw2">&lt;/html&gt;</span></span></div>
</div>
<p>Add the following <strong>div</strong> tags between the <strong>BODY </strong>tags:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="sc2"><a href="http://december.com/html/4/element/div.html"><span class="kw2">&lt;div</span></a> <span class="kw3">id</span>=<span class="st0">&#034;wrapper&#034;</span><span class="kw2">&gt;</span></a></span><br />
&nbsp; &nbsp; <span class="sc2"><a href="http://december.com/html/4/element/div.html"><span class="kw2">&lt;div</span></a> <span class="kw3">id</span>=<span class="st0">&#034;header&#034;</span><span class="kw2">&gt;</span></a></span><span class="sc2"><span class="kw2">&lt;/div&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc2"><a href="http://december.com/html/4/element/div.html"><span class="kw2">&lt;div</span></a> <span class="kw3">id</span>=<span class="st0">&#034;content&#034;</span><span class="kw2">&gt;</span></a></span><span class="sc2"><span class="kw2">&lt;/div&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc2"><a href="http://december.com/html/4/element/div.html"><span class="kw2">&lt;div</span></a> <span class="kw3">id</span>=<span class="st0">&#034;footer&#034;</span><span class="kw2">&gt;</span></a></span><span class="sc2"><span class="kw2">&lt;/div&gt;</span></span><br />
<span class="sc2"><span class="kw2">&lt;/div&gt;</span></span></div>
</div>
<p>Now it&#039;s time for the CSS. Create the new CSS file (<strong>design.css</strong>) and add the following CSS code:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1">@charset &quot;utf-8&quot;;</span><br />
<span class="coMULTI">/* CSS Document */</span></p>
<p>body <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">margin</span>: <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">padding</span>: <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">font-family</span>: <span class="st0">&#034;Century Gothic&#034;</span>, Arial, <span class="kw2">sans-serif</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">color</span>: #333333;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">font-size</span>: 12px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">text-align</span>: <span class="kw2">center</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">background</span>: <span class="kw2">url</span><span class="br0">&#40;</span>img/main_bg.png<span class="br0">&#41;</span> <span class="kw2">repeat-x</span> #302a1d;<br />
<span class="br0">&#125;</span></p>
<p><span class="re0">#wrapper <span class="br0">&#123;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">width</span>: 1024px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">margin</span>: <span class="kw2">auto</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">text-align</span>: <span class="kw1">left</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="re0">#header <span class="br0">&#123;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">background</span>: <span class="kw2">url</span><span class="br0">&#40;</span>img/header.png<span class="br0">&#41;</span> <span class="kw2">no-repeat</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">height</span>: 170px;<br />
<span class="br0">&#125;</span></p>
<p><span class="re0">#content <span class="br0">&#123;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">background</span>: <span class="kw2">url</span><span class="br0">&#40;</span>img/content_bg.png<span class="br0">&#41;</span> <span class="kw2">repeat-y</span>;<br />
<span class="br0">&#125;</span></p>
<p>#content h1 <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">font-weight</span>: <span class="kw2">normal</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">font-size</span>: 36px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">color</span>: #918977;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">margin</span>: <span class="nu0">0</span> 80px 5px 80px;<br />
<span class="br0">&#125;</span></p>
<p>#content p <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">margin</span>: <span class="nu0">0</span> 80px 5px 80px;<br />
<span class="br0">&#125;</span></p>
<p><span class="re0">#footer <span class="br0">&#123;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">background</span>: <span class="kw2">url</span><span class="br0">&#40;</span>img/footer.png<span class="br0">&#41;</span> <span class="kw2">no-repeat</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">height</span>: 90px;<br />
<span class="br0">&#125;</span></div>
</div>
<p>Now, attach the stylesheet to your XHTML document using:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="sc2"><a href="http://december.com/html/4/element/link.html"><span class="kw2">&lt;link</span></a> <span class="kw3">href</span>=<span class="st0">&#034;design.css&#034;</span> <span class="kw3">rel</span>=<span class="st0">&#034;stylesheet&#034;</span> <span class="kw3">type</span>=<span class="st0">&#034;text/css&#034;</span> <span class="kw3">media</span>=<span class="st0">&#034;screen&#034;</span> /<span class="kw2">&gt;</span></a></span></div>
</div>
<p>anywhere between the <strong>HEAD </strong>tags.</p>
<p>Voila! We&#039;re done!</p>
<h3>Extras</h3>
<p>Play around with this simple layout design, create new images, change colours and edit the CSS. Take a look at my <a href="http://www.edrackham.com/tutorials/simple-web20-layout-in-photoshop/" title="My final design">final design</a>.</p>
<p>I changed the header image to include a logo and some links, and also added some images to the footer. It seems to be the web2.0 style that you incorporate faint logos at the bottom of your layout.</p>
<p><a href='http://www.mediafire.com/?m1umgjhexzv' title="Download all the files used in this tutorial"><img src="http://edrackham.com/images/download_tut_files.png" alt="Download Tutorial Files" border="0" /></a></p>
<p><a href="http://www.edrackham.com/tutorials/simple-web20-layout-in-photoshop/" title="My final design"><img src="http://edrackham.com/images/view_it.png" alt="View Final Design" border="0" /></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>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/css/simple-web-20-design-and-css-tutorial/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Online .htpasswd Generator</title>
		<link>http://edrackham.com/apache/online-htpasswd-generator/</link>
		<comments>http://edrackham.com/apache/online-htpasswd-generator/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 13:51:25 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[.htaccess]]></category>

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

		<category><![CDATA[Tools]]></category>
<category>generator</category><category>htpasswd</category><category>prevent access</category><category>secure directory</category><category>Tools</category>
		<guid isPermaLink="false">http://edrackham.com/apache/online-htpasswd-generator/</guid>
		<description><![CDATA[Use the following .htpasswd generator to secure your Apache web directories.
Your browser does not support IFRAMES. Please view the generator at http://edrackham.com/tutorials/online-htpasswd-generator/
Make sure you have a .htaccess and .htpasswd file in the directory you want to secure, then add the entries once you&#039;ve generated your password.






]]></description>
			<content:encoded><![CDATA[<p>Use the following .htpasswd generator to secure your Apache web directories.</p>
<p><iframe id="htpasswd_generator" name="htpasswd_generator" width="460" scrolling="no" height="130" frameborder="0" src="http://edrackham.com/tutorials/online-htpasswd-generator/?iframe">Your browser does not support IFRAMES. Please view the generator at http://edrackham.com/tutorials/online-htpasswd-generator/</iframe></p>
<p>Make sure you have a .htaccess and .htpasswd file in the directory you want to secure, then add the entries once you&#039;ve generated your password.</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>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/apache/online-htpasswd-generator/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Online MD5 Hash Generator</title>
		<link>http://edrackham.com/tools/online-md5-hash-generator/</link>
		<comments>http://edrackham.com/tools/online-md5-hash-generator/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 10:38:41 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[Tools]]></category>
<category>MD5 Hash</category><category>PHP</category><category>Tools</category>
		<guid isPermaLink="false">http://edrackham.com/tools/online-md5-hash-generator/</guid>
		<description><![CDATA[Here is a simple MD5 hash generator I created quickly as part of a useful toolset I&#039;m planning to build up.
Your browser doesn&#039;t support IFRAMES. You can see the MD5 hash generator here.
The code to generate an MD5 hash using PHP is simple:

md5&#40;$string_to_convert&#41;;







]]></description>
			<content:encoded><![CDATA[<p>Here is a simple MD5 hash generator I created quickly as part of a useful toolset I&#039;m planning to build up.</p>
<p><iframe frameborder="0" src="http://edrackham.com/tutorials/online-md5-hash-generator/?iframe" height="80px" width="460px" scrolling="no">Your browser doesn&#039;t support IFRAMES. You can see the MD5 hash generator <a href="http://edrackham.com/tutorials/online-md5-hash-generator/" title="Simple Online MD5 Hash Generator">here</a>.</iframe></p>
<p>The code to generate an MD5 hash using PHP is simple:</p>
<div class="codesnip-container" >
<div class="codesnip"><a href="http://www.php.net/md5"><span class="kw3">md5</span></a><span class="br0">&#40;</span><span class="re0">$string_to_convert</span><span class="br0">&#41;</span>;</div>
</div>
<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>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/tools/online-md5-hash-generator/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Top 10 .htaccess Tips and Tricks</title>
		<link>http://edrackham.com/apache/top-10-htaccess-tips-and-tricks/</link>
		<comments>http://edrackham.com/apache/top-10-htaccess-tips-and-tricks/#comments</comments>
		<pubDate>Thu, 06 Mar 2008 00:23:39 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[.htaccess]]></category>

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

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

		<category><![CDATA[tricks]]></category>
<category>.htaccess</category><category>apache</category><category>tips</category><category>tricks</category>
		<guid isPermaLink="false">http://edrackham.com/apache/top-10-htaccess-tips-and-tricks/</guid>
		<description><![CDATA[Custom Error Documents
Creating custom documents gives your site a more professional look, as not only are you providing a &#039;net&#039; to catch unsuspecting visitors when they follow a bad link and such like, but they also allow you to customise the style of the page so you can maintain your basic site design by adding [...]]]></description>
			<content:encoded><![CDATA[<h4>Custom Error Documents</h4>
<p>Creating custom documents gives your site a more professional look, as not only are you providing a &#039;net&#039; to catch unsuspecting visitors when they follow a bad link and such like, but they also allow you to customise the style of the page so you can maintain your basic site design by adding HTML.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1"># custom error documents</span><br />
<span class="kw1">ErrorDocument</span> <span class="nu0">401</span> /error/<span class="nu0">401</span>.php<br />
<span class="kw1">ErrorDocument</span> <span class="nu0">403</span> /error/<span class="nu0">403</span>.php<br />
<span class="kw1">ErrorDocument</span> <span class="nu0">404</span> /error/<span class="nu0">404</span>.php<br />
<span class="kw1">ErrorDocument</span> <span class="nu0">500</span> /error/<span class="nu0">500</span>.php</div>
</div>
<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>
<h4>Control Access</h4>
<p>Being able to control access to certain areas of your server can be very useful. The following example demonstrates how to only allow access from those connecting from a 192.168.0 LAN IP pool. This could be easily modified to only allow access from a single remote IP address or addresses.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1"># no nasty crackers in here!</span><br />
<span class="kw1">order</span> <span class="kw1">deny</span>,<span class="kw1">allow</span><br />
<span class="kw1">deny</span> <span class="kw1">from</span> <span class="kw1">all</span><br />
<span class="kw1">allow</span> <span class="kw1">from</span> <span class="nu0">192</span>.<span class="nu0">168</span>.<span class="nu0">0</span>.<span class="nu0">0</span>/<span class="nu0">24</span><br />
<span class="co1"># this would do the same thing..</span><br />
<span class="co1">#allow from 192.168.0 </span><br />
&nbsp;</div>
</div>
<h4>Hide and Deny Files</h4>
<p>Hiding and denying access to files is crucial to servers that have sensitive data held within files that may be accessible via the website(s) on it. The following example demonstrates how to prevent acces to any files ending with .log - and is case insensitive (i.e. .LoG / .lOG / .loG).</p>
<div class="codesnip-container" >
<div class="codesnip">&lt;Files ~ <span class="st0">&#034;^.*<span class="es0">\.</span>([Ll][Oo][Gg])&#034;</span>&gt;<br />
&nbsp;<span class="kw1">Order</span> <span class="kw1">allow</span>,<span class="kw1">deny</span><br />
&nbsp;<span class="kw1">Deny</span> <span class="kw1">from</span> <span class="kw1">all</span><br />
&nbsp;<span class="kw1">Satisfy</span> <span class="kw1">All</span><br />
&lt;/Files&gt;</div>
</div>
<h4>Basic Rewriting</h4>
<p>I have written a <a href="http://edrackham.com/apache/beginners-mod_rewrite-tutorial/" title="mod_rewrite tutorial">mod_rewrite tutorial</a>, but this is worth a mention as a top 10 tip for .htaccess files as it&#039;s becoming more and more commonly used these days - primarily for SEO purposes.</p>
<p>This example will redirect a request for <strong>http://edrackham.com/page_one.htm</strong> to <strong>http://edrackham.com/page_one.php</strong>. The <em>r=301</em> tells apache to send a proper HTTP <em>Permanently Moved</em> redirection (301), which will update the address bar in the browser window to show &#039;page_one.php&#039;. Without this, you&#039;d still see &#039;page_one.htm&#039; even though you&#039;re seeing a PHP page. This helps SEO, as spiders and search engines will update their listings to reflect the PHP versions.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw1">Options</span> +<span class="kw2">FollowSymlinks</span><br />
<span class="kw1">RewriteEngine</span> <span class="kw2">on</span><br />
<span class="kw1">RewriteRule</span> ^<span class="br0">&#40;</span>.+<span class="br0">&#41;</span>\.htm$ http://edrackham.com/$<span class="nu0">1</span>.php <span class="br0">&#91;</span>r=<span class="nu0">301</span>,nc<span class="br0">&#93;</span></div>
</div>
<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>
<h4>Shorter URLs</h4>
<p>Shorter URLs are beneficial, as visitors that persist in typing full URLs won&#039;t have to type as much, and they&#039;re more memorable. Do they benefit SEO, even though the full URL contains the same keywords? I don&#039;t know, maybe someone can tell me.</p>
<p>This example will rewrite a page requested as <strong>http://edrackham.com/files/code/apache.zip</strong> to <strong>http://edrackham.com/download.php?type=code&amp;file=apache</strong>.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw1">Options</span> +<span class="kw2">FollowSymlinks</span><br />
<span class="kw1">RewriteEngine</span> <span class="kw2">on</span><br />
<span class="kw1">RewriteRule</span> ^<span class="kw1">files</span>/<span class="br0">&#40;</span>.+<span class="br0">&#41;</span>/<span class="br0">&#40;</span>.+<span class="br0">&#41;</span>.zip download.php?type=$<span class="nu0">1</span>&amp;file=$<span class="nu0">2</span> <span class="br0">&#91;</span>nc<span class="br0">&#93;</span></div>
</div>
<h4>Prevent Hotlinking</h4>
<p>Preventing hotlinking can reduce bandwidth, by disallowing other websites from displaying images hosted on your server. The following rule basically says that if the referer is NOT edrackham.com, run the following rule. The rule (on the next line) says that if the request is for a .gif, .jpg or.png then redirect the visitor to http://edrackham.com/img/hotlink_f_o.png. I&#039;ll leave you to work out what the &#039;f_o&#039; stands for.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw1">Options</span> +<span class="kw2">FollowSymlinks</span><br />
<span class="co1"># no hot-linking</span><br />
<span class="kw1">RewriteEngine</span> <span class="kw2">On</span><br />
<span class="kw1">RewriteCond</span> %<span class="br0">&#123;</span>HTTP_REFERER<span class="br0">&#125;</span> !^$<br />
<span class="kw1">RewriteCond</span> %<span class="br0">&#123;</span>HTTP_REFERER<span class="br0">&#125;</span> !^http://<span class="br0">&#40;</span>www\.<span class="br0">&#41;</span>?edrackham\.com/ <span class="br0">&#91;</span>nc<span class="br0">&#93;</span><br />
<span class="kw1">RewriteRule</span> .*\.<span class="br0">&#40;</span>gif|jpg|png<span class="br0">&#41;</span>$ http://edrackham.com/img/hotlink_f_o.png <span class="br0">&#91;</span>nc<span class="br0">&#93;</span></div>
</div>
<h4>Hiding Page Extension</h4>
<p>Similar to the mod_rewrite code above, this will redirect a request for <strong>product-<em>3</em>.html</strong> to <strong>products.php?id=<em>3</em></strong>. As we&#039;re not using <em>r=301</em>, the requested page will remain in the browser&#039;s address bar.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw1">Options</span> +<span class="kw2">FollowSymlinks</span><br />
<span class="kw1">RewriteEngine</span> <span class="kw2">on</span><br />
<span class="kw1">RewriteRule</span> ^product-<span class="br0">&#40;</span><span class="br0">&#91;</span><span class="nu0">0</span>-<span class="nu0">9</span><span class="br0">&#93;</span>+<span class="br0">&#41;</span>\.html$ products.php?id=$<span class="nu0">1</span></div>
</div>
<h4>Ban Selected User Agents</h4>
<p>In my opinion, it&#039;d be ace to block all requests from a Microsoft user agent, but alas, that wouldn&#039;t be too cool as some people are still hell-bent on using a non-standards compliant browser. Having said that, Microsoft is making their new <a href="http://edrackham.com/web-standards/standards-compliant-internet-explorer-ie8/" title="Microsoft to release standards compliant browser. Yes really!">IE8 release standards compliant</a> by default.</p>
<p>The following provides some examples for blocking requests to your server from certain user agents.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1">#####################################</span><br />
<span class="co1"># Deny Useragents</span><br />
<span class="co1">#####################################</span></p>
<p><span class="kw1">RewriteCond</span> %<span class="br0">&#123;</span>HTTP_USER_AGENT<span class="br0">&#125;</span> ^FrontPage <span class="br0">&#91;</span>NC,OR<span class="br0">&#93;</span><br />
<span class="kw1">RewriteCond</span> %<span class="br0">&#123;</span>HTTP_USER_AGENT<span class="br0">&#125;</span> ^Java.* <span class="br0">&#91;</span>NC,OR<span class="br0">&#93;</span><br />
<span class="kw1">RewriteCond</span> %<span class="br0">&#123;</span>HTTP_USER_AGENT<span class="br0">&#125;</span> ^Microsoft.URL <span class="br0">&#91;</span>NC,OR<span class="br0">&#93;</span><br />
<span class="kw1">RewriteCond</span> %<span class="br0">&#123;</span>HTTP_USER_AGENT<span class="br0">&#125;</span> ^MSFrontPage <span class="br0">&#91;</span>NC,OR<span class="br0">&#93;</span><br />
<span class="kw1">RewriteCond</span> %<span class="br0">&#123;</span>HTTP_USER_AGENT<span class="br0">&#125;</span> ^Offline.Explorer <span class="br0">&#91;</span>NC,OR<span class="br0">&#93;</span><br />
<span class="kw1">RewriteCond</span> %<span class="br0">&#123;</span>HTTP_USER_AGENT<span class="br0">&#125;</span> ^<span class="br0">&#91;</span>Ww<span class="br0">&#93;</span>eb<span class="br0">&#91;</span>Bb<span class="br0">&#93;</span>andit <span class="br0">&#91;</span>NC,OR<span class="br0">&#93;</span><br />
<span class="kw1">RewriteCond</span> %<span class="br0">&#123;</span>HTTP_USER_AGENT<span class="br0">&#125;</span> ^Zeus <span class="br0">&#91;</span>NC<span class="br0">&#93;</span><br />
<span class="kw1">RewriteRule</span> ^.*$ - <span class="br0">&#91;</span>F<span class="br0">&#93;</span></div>
</div>
<h4>Making Other Filetypes Executable</h4>
<p>Ever wanted to make your site look like it runs off a new language such as .w00t files? Well you can with .htaccess! Adding this neat one-liner, you can request .w00t files, which will be served and interpreted as .php type files.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw1">AddType</span> application/x-httpd-php .w00t</div>
</div>
<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>
<h4>Force Media Downloads</h4>
<p>Sometimes, when clicking on media files, the browser wants to play or stream it directly from itself. Using the following rules, media files (.avi/.mpg/.wmv/.mp3 in this example) will provide a download dialog box instead.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1"># instruct browser to download multimedia files</span><br />
<span class="kw1">AddType</span> application/octet-stream .avi<br />
<span class="kw1">AddType</span> application/octet-stream .mpg<br />
<span class="kw1">AddType</span> application/octet-stream .wmv<br />
<span class="kw1">AddType</span> application/octet-stream .mp3</div>
</div>
<h4>Require SSL</h4>
<p>Sometimes you will require an SSL connection. This following snippet will do just that!</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1"># require SSL</span><br />
SSLOptions +StrictRequire<br />
SSLRequireSSL<br />
SSLRequire %<span class="br0">&#123;</span>HTTP_HOST<span class="br0">&#125;</span> eq <span class="st0">&#034;domain.tld&#034;</span><br />
<span class="kw1">ErrorDocument</span> <span class="nu0">403</span> https://domain.tld</p>
<p><span class="co1"># require SSL without mod_ssl</span><br />
<span class="kw1">RewriteCond</span> %<span class="br0">&#123;</span>HTTPS<span class="br0">&#125;</span> !=<span class="kw2">on</span> <span class="br0">&#91;</span>NC<span class="br0">&#93;</span><br />
<span class="kw1">RewriteRule</span> ^.*$ https://%<span class="br0">&#123;</span>SERVER_NAME<span class="br0">&#125;</span>%<span class="br0">&#123;</span>REQUEST_URI<span class="br0">&#125;</span> <span class="br0">&#91;</span>R,L<span class="br0">&#93;</span></div>
</div>
<p>Sources:<br />
http://corz.org/serv/tricks/htaccess.php<br />
http://roshanbh.com.np/2008/02/hide-php-url-rewriting-htaccess.html<br />
http://expressproducts.net/htaccess.htm<br />
http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/#usa4<br />
http://phpsecurity.wordpress.com/2007/12/22/htaccess-tips-and-tricks/</p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/apache/top-10-htaccess-tips-and-tricks/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Get Random Row with MySQL Without ORDER BY RAND()</title>
		<link>http://edrackham.com/featured/get-random-row-with-mysql-without-order-by-rand/</link>
		<comments>http://edrackham.com/featured/get-random-row-with-mysql-without-order-by-rand/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 12:12:24 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[Featured]]></category>

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

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

		<category><![CDATA[random row]]></category>
<category>fast</category><category>MySQL</category><category>random row</category>
		<guid isPermaLink="false">http://edrackham.com/mysql/get-random-row-with-mysql-without-rand/</guid>
		<description><![CDATA[This is an update to a previous post of mine which uses the RAND() method. Using the following code, you can retrieve a random row much, much faster (MySQL 4.1.x/5.0.x), with thanks to Jan Kneschke:

SELECT &#60;COLUMN&#62; FROM &#60;TABLE&#62; AS r1
JOIN &#40;SELECT ROUND&#40;
&#160; RAND&#40; &#41; * &#40;
&#160; &#160; SELECT MAX&#40; id &#41; FROM &#60;TABLE&#62;&#41;
&#160; &#41; AS [...]]]></description>
			<content:encoded><![CDATA[<p>This is an update to a <a href="http://edrackham.com/php/get-random-row-with-mysql/" title="Slower, but useful for smaller tables">previous post of mine</a> which uses the RAND() method. Using the following code, you can retrieve a random row much, much faster (MySQL 4.1.x/5.0.x), with thanks to Jan Kneschke:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw1">SELECT</span> &lt;COLUMN&gt; <span class="kw1">FROM</span> &lt;TABLE&gt; <span class="kw1">AS</span> r1<br />
<span class="kw1">JOIN</span> <span class="br0">&#40;</span><span class="kw1">SELECT</span> ROUND<span class="br0">&#40;</span><br />
&nbsp; RAND<span class="br0">&#40;</span> <span class="br0">&#41;</span> * <span class="br0">&#40;</span><br />
&nbsp; &nbsp; <span class="kw1">SELECT</span> MAX<span class="br0">&#40;</span> id <span class="br0">&#41;</span> <span class="kw1">FROM</span> &lt;TABLE&gt;<span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#41;</span> <span class="kw1">AS</span> id<br />
<span class="br0">&#41;</span> <span class="kw1">AS</span> r2<br />
<span class="kw1">WHERE</span> r1.id &gt;= r2.id<br />
<span class="kw1">ORDER</span> <span class="kw1">BY</span> r1.id <span class="kw1">ASC</span><br />
<span class="kw1">LIMIT</span> <span class="nu0">1</span>;</div>
</div>
<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>Replace:</p>
<ul>
<li><strong>&lt;COLUMN&gt;</strong> with the name of the column(s) you wish to retrieve</li>
<li><strong>&lt;TABLE&gt;</strong> with the name of the table you wish to retrieve the data from</li>
</ul>
<p>I&#039;ve tested this with a table with over 660,000 records, and got a response in 0.0200 seconds, whereas with ORDER BY RAND() i got a response in 2.1599 seconds.</p>
<h4>Total Number of Rows:</h4>
<p><img src="http://edrackham.com/images/posts/num-rows.gif" alt="Cardinality" style="border:1px solid #ccc" /></p>
<h4>Old Method:</h4>
<p><img src="http://edrackham.com/images/posts/faster-rand-mysql-old-query.gif" alt="Old Method" style="border:1px solid #ccc" /></p>
<h4>New Method:</h4>
<p><img src="http://edrackham.com/images/posts/faster-rand-mysql-new-query.gif" alt="New Method" style="border:1px solid #ccc" /></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>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/featured/get-random-row-with-mysql-without-order-by-rand/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Standards Compliant Internet Explorer (IE8)</title>
		<link>http://edrackham.com/web-standards/standards-compliant-internet-explorer-ie8/</link>
		<comments>http://edrackham.com/web-standards/standards-compliant-internet-explorer-ie8/#comments</comments>
		<pubDate>Tue, 04 Mar 2008 21:36:00 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
		
		<category><![CDATA[Web Standards]]></category>

		<category><![CDATA[IE8]]></category>
<category>IE8</category><category>Web Standards</category>
		<guid isPermaLink="false">http://edrackham.com/web-standards/standards-compliant-internet-explorer-ie8/</guid>
		<description><![CDATA[We’ve decided that IE8 will, by default, interpret web content in the most standards compliant way it can. This decision is a change from what we’ve posted previously.
Don your glad rags and party hats, it&#039;s time to celebrate! Microsoft have announced that their new interoperable release of Internet Explorer (IE8) will be standards compliant by [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>We’ve decided that IE8 will, by default, interpret web content in the most standards compliant way it can. This decision is a change from what we’ve posted previously.</p></blockquote>
<p>Don your glad rags and party hats, it&#039;s time to celebrate! Microsoft have announced that their new interoperable release of <a href="http://blogs.msdn.com/ie/archive/2008/03/03/microsoft-s-interoperability-principles-and-ie8.aspx" title="Let's hope so...">Internet Explorer (IE8) will be standards compliant by default</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>Their explaination for change still hints at their stubborness though: <em>&#034;While we do not believe any current legal requirements would dictate which rendering mode a browser must use, this step clearly removes this question as a potential legal and regulatory issue.&#034;</em>.</p>
<h3>So what does this mean for us as designers?</h3>
<p>Don&#039;t misconceive me - I&#039;m not primarily a designer, but I do design all sites I build &#8230;in pure CSS. This change will mean that we should know that our designs will render the same in all mainstream browsers such as FireFox, Opera, Safari and of course IE8 (provided we use valid CSS1, 2 or 3 [when fully supported] code). The days of running both FireFox and IE6/7, uploading your new CSS file and hitting F5 to find that the bug you just fixed in IE6/7 has now broken something else layout-wise should now be gone.</p>
<p>IE8 will support standards compliant mode as default, but will be backward compatible with our already &#039;IE Bug-Fixed&#039; CSS files. So, to save us backtracking to make our previously written CSS files - which have no doubt taken us hours upon hours to write thanks to IE7- rendering modes - we can insert a meta tag into IE8 to set it to &#034;Quirks Mode&#034; for this exact purpose.</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>
<h3>A final note</h3>
<p>All in all, I don&#039;t have much confidence in Microsoft and the web. This confidence decreases even more after hearing any one of Steve Ballmer&#039;s semitars, especially the one about Microsoft winning the web. In my opinion, they never will, but this is a fantastic step in the right direction which leads me to say two things; Well done Microsoft, and two, Let&#039;s get used to the days of IE7-.</p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/web-standards/standards-compliant-internet-explorer-ie8/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
