<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>html tutorials &#124; css tutorials &#124; php tutorials &#124; Nodstrum Blog &#187; Code</title>
	<atom:link href="http://www.nodstrum.com/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nodstrum.com</link>
	<description>A coders playground.</description>
	<lastBuildDate>Tue, 04 May 2010 22:12:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Shorthand PHP IF/ELSE Statements = much shorter code!</title>
		<link>http://www.nodstrum.com/2008/02/14/shorthand-php-ifelse-statements-much-shorter-code/</link>
		<comments>http://www.nodstrum.com/2008/02/14/shorthand-php-ifelse-statements-much-shorter-code/#comments</comments>
		<pubDate>Thu, 14 Feb 2008 11:27:47 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://nodstrum.com/2008/02/14/shorthand-php-ifelse-statements-much-shorter-code/</guid>
		<description><![CDATA[You may or may not have heard of shorthand if/else statements, but they do exist, and trust me they make things SO much more ordered in your code when used in the right way.
This is the Shorthand version &#8211; below this, if you cannot work it out for yourself is a nice description.

&#160; &#160; // [...]]]></description>
			<content:encoded><![CDATA[<p>You may or may not have heard of shorthand if/else statements, but they do exist, and trust me they make things SO much more ordered in your code when used in the right way.</p>
<p>This is the Shorthand version &#8211; below this, if you cannot work it out for yourself is a nice description.</p>
<div class="dean_ch" style="white-space: wrap;">
&nbsp; &nbsp; <span class="co1">// Will print out &#8216;i am male&#8217; if $myGender is &#8216;male&#8217; and vice-versa.</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="br0">&#40;</span><span class="re0">$myGender</span> == <span class="st0">&#8216;male&#8217;</span> ? <span class="st0">&#8216;i am male&#8217;</span> : <span class="st0">&#8216;I am female&#8217;</span><span class="br0">&#41;</span>;</div>
<p><strong>Description of how this actually works</strong><br />
We all (i would hope) know the normal way of writing if/else statements (here is a recap just incase)</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="re0">$myVar</span> = <span class="kw2">true</span>;<br />
<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$myVar</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;My Var is TRUE!&#8217;</span>;<br />
<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;My Var is FALSE&#8217;</span>;<br />
<span class="br0">&#125;</span></div>
<p>That sort of statement is great for in the body of your code, but when want a dynamic selector within your HTML code, it gets very messy.</p>
<p>EG:</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$myGender</span> == <span class="st0">&#8216;male&#8217;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co1">// Gender is MALE.</span><br />
&nbsp; &nbsp; <span class="re0">$maleOpt</span> = <span class="st0">&#8217;selected&#8217;</span>;<br />
&nbsp; &nbsp; <span class="re0">$femaleOpt</span> = <span class="st0">&#8221;</span>;<br />
<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co1">// Gender is FEMALE.</span><br />
&nbsp; &nbsp; <span class="re0">$maleOpt</span> = <span class="st0">&#8221;</span>;<br />
&nbsp; &nbsp; <span class="re0">$femaleOpt</span> = <span class="st0">&#8217;selected&#8217;</span>;<br />
<span class="br0">&#125;</span></div>
<div class="dean_ch" style="white-space: wrap;">
&lt;select name=&quot;gender&quot;&gt;&lt;<br />
option value=&quot;female&quot; &lt;?= $femaleOpt; ?&gt;&gt;Female&lt;/option&gt;<br />
&lt;option value=&quot;male&quot; &lt;?= $maleOpt; ?&gt;&gt;Male&lt;/option&gt;<br />
&lt;/select&gt;<br />
&nbsp;</div>
<p>Now &#8211; that is alot to write and will make your HTML form look a total mess, this is where the shorthand comes in.  It allows us to write the same thing inline</p>
<p>Look:</p>
<div class="dean_ch" style="white-space: wrap;">
&lt;select name=&quot;gender&quot;&gt; <br />
&lt;option value=&quot;female&quot; &lt;?= ($myGender == &#8216;female&#8217; ? &#8217;selected&#8217; : &#8221;); ?&gt;&gt;Female&lt;/option&gt;<br />
&lt;option value=&quot;male&quot; &lt;?= ($myGender == &#8216;male&#8217; ? &#8217;selected&#8217; : &#8221;); ?&gt;&gt;Male&lt;/option&gt;<br />
&lt;/select&gt;<br />
&nbsp;</div>
<p>As you can see &#8211; there is a huge difference in the amount of code &#8211; and if Wordpress formatted it nicely &#8211; it would look loads better!</p>
<p><strong>And the all important Explanation!</strong></p>
<div class="dean_ch" style="white-space: wrap;">
<span class="co1">// This will echo selected to the screen if $myGender is male.</span><br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="br0">&#40;</span><span class="re0">$myGender</span> = <span class="st0">&#8216;male&#8217;</span> ? <span class="st0">&#8216; selected&#8217;</span> : <span class="st0">&#8221;</span><span class="br0">&#41;</span>;<br />
&nbsp;</div>
<p>So &#8211; $myGender is the variable we are checking, in this case we are checking to see if $myGender == &#8216;male&#8217;</p>
<p>The questionmark (?) seperates the &#8216;answers&#8217;.</p>
<p>The first &#8216;answer&#8217; is what is set/displayed when the query is true, the second is if the query is false.</p>
<p>This is the equilivent to :</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$myGender</span> == <span class="st0">&#8216;male&#8217;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8217;selected&#8217;</span>;<br />
<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8221;</span>;<br />
<span class="br0">&#125;</span></div>
<p>Hope that helps some of you out!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nodstrum.com/2008/02/14/shorthand-php-ifelse-statements-much-shorter-code/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Captcha &#8211; in 5 lines of php :)</title>
		<link>http://www.nodstrum.com/2007/09/23/captcha/</link>
		<comments>http://www.nodstrum.com/2007/09/23/captcha/#comments</comments>
		<pubDate>Sun, 23 Sep 2007 08:08:18 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://nodstrum.com/2007/09/23/captcha/</guid>
		<description><![CDATA[Yes you read it right&#8230;! 5 lines of code  
I know its hard to believe but this has to be one of the simplest implementation of Captcha, mainly because i can&#8217;t find any easier ones.
So here goes, this is how it works:
At the top of the page with the form you want to Captcha [...]]]></description>
			<content:encoded><![CDATA[<p>Yes you read it right&#8230;! <span style="font-weight: bold" class="Apple-style-span">5 lines of code <img src='http://www.nodstrum.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </span></p>
<p><span style="font-weight: bold" class="Apple-style-span"></span>I know its hard to believe but this has to be one of the simplest implementation of Captcha, mainly because i can&#8217;t find any easier ones.</p>
<p>So here goes, this is how it works:</p>
<p>At the top of the page with the form you want to Captcha protect add these 3 lines of code, this generates the Captcha and adds it all to a nice variable to print out later:</p>
<div class="dean_ch" style="white-space: wrap;">
&nbsp; &nbsp; <span class="kw1">require_once</span><span class="br0">&#40;</span><span class="st0">&#8216;captcha.class.php&#8217;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; <span class="re0">$captcha</span> = <span class="kw2">new</span> Captcha;</p>
<p>&nbsp; &nbsp; <span class="re0">$captchaImage</span> = <span class="re0">$captcha</span>-&gt;<span class="me1">create</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
<p>Then in your form where you want the Captcha, usually at the bottom, just above the submit button add this line, enclosed in php tags of course, this adds the captcha elements to the form:</p>
<div class="dean_ch" style="white-space: wrap;"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="re0">$captchaImage</span>;</div>
<p>So that is the form part done, now we just need to verify what the user has put in. For this i am going to assume that you are verifying atleast one part of the users input, so we need to add this line into it:</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="re0">$captcha</span>-&gt;<span class="me1">verify</span><span class="br0">&#40;</span><span class="re0">$_POST</span><span class="br0">&#91;</span><span class="re0">$captcha</span>-&gt;<span class="me1">captchaInputName</span><span class="br0">&#93;</span><span class="br0">&#41;</span>;</div>
<p>This would probably fit into your current checking like so:</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$someothervariable</span> &amp;amp;&amp;amp; <span class="br0">&#40;</span><span class="re0">$captcha</span>-&gt;<span class="me1">verify</span><span class="br0">&#40;</span><span class="re0">$_POST</span><span class="br0">&#91;</span><span class="re0">$captcha</span>-&gt; <span class="me1">captchaInputName</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>&#8230;</div>
<p>Of course we have to add these 2 lines at the top of this processing page aswell (these are not included in the &#8216;5&#8242; because they have already been added.</p>
<div class="dean_ch" style="white-space: wrap;">
&nbsp; &nbsp; <span class="kw1">require_once</span><span class="br0">&#40;</span><span class="st0">&#8216;captcha.class.php&#8217;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; <span class="re0">$captcha</span> = <span class="kw2">new</span> Captcha;</div>
<p>And thats it, the class handles everything else, well you have to put the files on your web-server, create a new directory to store the images and make it writeable, but thats a one-shot 10 second job!</p>
<p><strong>Now for a screenshot:</strong></p>
<p><strong><img src="http://res.nodstrum.com/captcha/screenshots/screenshot_1.png" /></strong></p>
<p>Now for demo and the code:</p>
<p><a href="http://nodstrum.com/wp-content/plugins/DownloadCounter/download.php?id=28">Captcha DEMO </a></p>
<p><a href="http://nodstrum.com/wp-content/plugins/DownloadCounter/download.php?id=29">Captcha Formatted Source </a></p>
<p><a href="http://nodstrum.com/wp-content/plugins/DownloadCounter/download.php?id=27">Captcha ZIP </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nodstrum.com/2007/09/23/captcha/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>MySQL Calendar</title>
		<link>http://www.nodstrum.com/2007/06/27/mysql-calendar/</link>
		<comments>http://www.nodstrum.com/2007/06/27/mysql-calendar/#comments</comments>
		<pubDate>Wed, 27 Jun 2007 10:57:10 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://nodstrum.com/2007/06/27/mysql-calendar/</guid>
		<description><![CDATA[VERSION 1.1 RELEASED!
Changes: Added (by popular demand) Event deletion! 
Ok&#8230; I have finally got this script working!
I have not done it like a tutorial because it is just too big, so here are a load of screen shots, There is a link to a fully functional demo and zip at the bottom!
A little setup information:
1. [...]]]></description>
			<content:encoded><![CDATA[<p><strong>VERSION 1.1 RELEASED!</strong></p>
<p><em>Changes: Added (by popular demand) <strong>Event deletion</strong>! </em><br />
Ok&#8230; I have finally got this script working!</p>
<p>I have not done it like a tutorial because it is just too big, so here are a load of screen shots, <strong>There is a link to a fully functional demo and zip at the bottom!</strong></p>
<p><strong>A little setup information:</strong></p>
<p>1. Copy the entire calendar into whatever directory you want.</p>
<p>2. Create your database and import the &#8216;databaseSQL.sql&#8217; file into it, this will create the default data for running it.</p>
<p>3. Alter the &#8216;databaseConnection.php&#8217; file to show your connection details.That should be it..</p>
<p>NOTE:By default the username and password are both &#8216;<span class="Apple-style-span" style="font-weight: bold">admin</span>&#8216; (without the quotes), i suggest you change your password in the control panel.</p>
<p>If you have any problems i will be happy to help, just post your query as a comment to this page.</p>
<p><strong>Screen Shots</strong></p>
<p><strong>Default View</strong></p>
<p><img src="http://res.nodstrum.com/mysqlCalendar/calendarScreenshots/defaultCalendar.png.png" /></p>
<p><span id="more-35"></span></p>
<p><strong>View Events</strong><br />
<img src="http://res.nodstrum.com/mysqlCalendar/calendarScreenshots/viewEvents.png" /></p>
<p><strong>View Events 2</strong><br />
<img src="http://res.nodstrum.com/mysqlCalendar/calendarScreenshots/noEvents.png" /></p>
<p><strong>Login</strong></p>
<p><img src="http://res.nodstrum.com/mysqlCalendar/calendarScreenshots/login.png" /></p>
<p><strong>Control Panel</strong></p>
<p><img src="http://res.nodstrum.com/mysqlCalendar/calendarScreenshots/controlPanel.png" /></p>
<p><strong>Add Event</strong></p>
<p><img src="http://res.nodstrum.com/mysqlCalendar/calendarScreenshots/addEvent1.png" /></p>
<p><strong>Add Event 2</strong></p>
<p><img src="http://res.nodstrum.com/mysqlCalendar/calendarScreenshots/addEvent2.png" /></p>
<p><strong>Downloads</strong></p>
<p><a href="http://nodstrum.com/wp-content/plugins/DownloadCounter/download.php?id=22">MySQL Calendar V1.1 DEMO</a></p>
<p><a href="http://nodstrum.com/wp-content/plugins/DownloadCounter/download.php?id=23">MySQL Calendar v1.1 ZIP</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nodstrum.com/2007/06/27/mysql-calendar/feed/</wfw:commentRss>
		<slash:comments>240</slash:comments>
		</item>
		<item>
		<title>AJAX/PHP &#8211; the beginners guide to loading external content</title>
		<link>http://www.nodstrum.com/2007/02/27/ajaxcontentload/</link>
		<comments>http://www.nodstrum.com/2007/02/27/ajaxcontentload/#comments</comments>
		<pubDate>Tue, 27 Feb 2007 12:08:54 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://nodstrum.com/2007/02/27/ajaxcontentload/</guid>
		<description><![CDATA[I&#8217;m going to assume that we all know, or have atleast heard of Prototype and script.aculo.us the two combine to form one powerful javascript library enabling developers to become designers (well, kind of).
&#8211; Example and code at the bottom &#8211;
I have created a ZIP file to get you up and running right away: Download it [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to assume that we all know, or have atleast heard of <a href="http://prototype.conio.net" target="_blank">Prototype</a> and <a href="http://script.aculo.us" target="_blank">script.aculo.us</a> the two combine to form one powerful javascript library enabling developers to become designers (well, kind of).<br />
<strong>&#8211; Example and code at the bottom &#8211;</strong></p>
<p><strong>I have created a ZIP file to get you up and running right away: <a href="http://nodstrum.com/wp-content/plugins/DownloadCounter/download.php?id=24">Download it now!</a></strong></p>
<p>I was showing a friend a few days ago something i made for a university module, Multimedia Applications Desgn (a mouthful i know). Basically we had to create a website promoting our group as a duo, thats all your getting about the project as its not really relevant and a tad embarrassing should anyone find the site!</p>
<p>There was a part of the site that my friend really liked and wanted to incorporate into his final year project&#8230; after sketching it out for him on paper i reconed that other people could benefit.<br />
This has probably been splashed everywhere, but i havent seen anything that incorporates all the same characteristics on <a href="http://digg.com" target="_blank">Digg</a>.</p>
<p>So here is a quick, hopefully easy to understand, tutorial of how its done.</p>
<p><strong>Abstract</strong><br />
We are trying to achieve loading content into a &#8216;div&#8217; element without refreshing the page, as well as showing a cool loading window inplace of the content as it is loading.</p>
<p><span id="more-11"></span></p>
<p><strong>Method</strong><br />
1 HTML page and 1 PHP page are required.<br />
You dont need to follow my method exactly as there are probably many many more out there, this is just my simple approach that seems to work.</p>
<p><strong>The HTML Page</strong><br />
This page will be the one we want the user to stay on with the &#8216;div&#8217; element in it for loading the content into.</p>
<p>Firstly we need to include the script.aculo.us javascript files.<br />
I just unzipped the script.aculo.us javascript files into my own folder called &#8216;js&#8217;.</p>
<div class="dean_ch" style="white-space: wrap;">
&lt;script src=<span class="st0">&quot;js/lib/prototype.js&quot;</span> type=<span class="st0">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;<br />
&lt;script src=<span class="st0">&quot;js/src/scriptaculous.js&quot;</span> type=<span class="st0">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;</div>
<p>Next we need to create a few functions to make our life easier.<br />
The reason for this is it makes them reuseable and therfore we dont need to make our code look messy, im a little anal about code being correctly formatted and using the same chunks of code over and over again when they could simply be made into functions.</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw2">function</span> startLoading<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// First we want to show the loading window then hide the content are we are loading into.</span><br />
&nbsp; Element.<span class="me1">show</span><span class="br0">&#40;</span><span class="st0">&#8216;mainAreaLoading&#8217;</span><span class="br0">&#41;</span>;<br />
&nbsp; Element.<span class="me1">hide</span><span class="br0">&#40;</span><span class="st0">&#8216;mainAreaInternal&#8217;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw2">function</span> finishLoading<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// First we want to show the content are, then toggle the loading window so it fades away.</span><br />
&nbsp; Element.<span class="me1">show</span><span class="br0">&#40;</span><span class="st0">&#8216;mainAreaInternel&#8217;</span><span class="br0">&#41;</span>;<br />
&nbsp; <span class="co1">// This happens 1 second after the mainAreaInternal is shown incase the content is still loading.</span><br />
&nbsp; setTimeout<span class="br0">&#40;</span><span class="st0">&quot;Effect.toggle(&#8216;mainAreaLoading&#8217;);&quot;</span>, <span class="nu0">1000</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw2">function</span> loadContent<span class="br0">&#40;</span>id<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// We make use of the Ajax.Updater function to load the external data from our file.</span><br />
&nbsp; <span class="co1">// Start the loading window first by calling the function we made previously.</span><br />
&nbsp; startLoading<span class="br0">&#40;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; <span class="co1">// Request the content and update the &#8216;div&#8217; area (i&#8217;ll explain this in more detail later).</span><br />
&nbsp; <span class="kw2">new</span> Ajax.<span class="me1">Updater</span><span class="br0">&#40;</span><span class="st0">&#8216;mainAreaInternal&#8217;</span>, <span class="st0">&#8216;rpc.php&#8217;</span>, <span class="br0">&#123;</span>method: <span class="st0">&#8216;post&#8217;</span>, postBody:<span class="st0">&#8216;content=&#8217;</span>+ id +<span class="st0">&#8221;</span><span class="br0">&#125;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; <span class="co1">// Now finish the loading.</span><br />
&nbsp; finishLoading<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></div>
<p>Next we have to make our &#8216;RPC file&#8217; (probably the wrong phrase to use, but it works for me).</p>
<p>Whatever you &#8216;echo&#8217; out to from this script will be what appears on the screen, html tags et-all, although i have found that outputting certain types of Javascript, like entire functions does not seem to work.</p>
<div class="dean_ch" style="white-space: wrap;">
&nbsp; <span class="co1">// We are posting our request, like the &#8216;method=&quot;post&quot;&#8217; in a form, so we need to catch it.</span><br />
&nbsp; <span class="re0">$content</span> = <span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st0">&#8216;content&#8217;</span><span class="br0">&#93;</span>;</p>
<p>&nbsp; <span class="co1">// The content to show is determined by the $content integer we send through from the javascript.</span><br />
&nbsp; <span class="kw1">switch</span><span class="br0">&#40;</span><span class="re0">$content</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">case</span> <span class="nu0">1</span>:<br />
&nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;This is the content for the FIRST case statement!&#8217;</span>;<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">break</span>;<br />
&nbsp; &nbsp; <span class="kw1">case</span> <span class="nu0">2</span>:<br />
&nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;Congratulations, you have loaded the second bit of content!&#8217;</span>;<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">break</span>;</p>
<p>&nbsp; &nbsp; <span class="kw2">default</span>:<br />
&nbsp; &nbsp; &nbsp; <span class="co1">// This default case catches any $content value that does not have a case. I&#8217;m giving a nice error message so you can work out what went wrong.</span><br />
&nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;Whoops, there was a problem in the switch.You passed: &lt;em&gt;&#8217;</span>. <span class="re0">$content</span> .<span class="st0">&#8216;&lt;/em&gt; to the switch statement in rpc.php.&#8217;</span>;<br />
&nbsp; <span class="br0">&#125;</span> <span class="co1">// end Content Switch.</span><br />
<span class="kw2">?&gt;</span></div>
<p>Here is the CSS Stylesheet to make all this possible</p>
<div class="dean_ch" style="white-space: wrap;">
&nbsp; <span class="re1">.mainAreaInternal</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">position</span>: <span class="kw2">absolute</span>;<br />
&nbsp; &nbsp; <span class="kw1">top</span>: <span class="re3">40px</span>;<br />
&nbsp; &nbsp; <span class="kw1">left</span>: <span class="re3">0px</span>;<br />
&nbsp; &nbsp; <span class="kw1">width</span>: <span class="re3">500px</span>;<br />
&nbsp; &nbsp; <span class="kw1">height</span>: <span class="re3">300px</span>;<br />
&nbsp; &nbsp; <span class="kw1">background-color</span>: <span class="re0">#cccccc</span>;</p>
<p>&nbsp; &nbsp; <span class="kw1">overflow</span>: <span class="kw2">auto</span>;<br />
&nbsp; &nbsp; <span class="kw1">z-index</span>: <span class="nu0">0</span>;<br />
&nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; <span class="re1">.mainAreaLoading</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">position</span>: <span class="kw2">absolute</span>;<br />
&nbsp; &nbsp; <span class="kw1">top</span>: <span class="re3">40px</span>;<br />
&nbsp; &nbsp; <span class="kw1">left</span>: <span class="re3">0px</span>;<br />
&nbsp; &nbsp; <span class="kw1">width</span>: <span class="re3">500px</span>;<br />
&nbsp; &nbsp; <span class="kw1">height</span>: <span class="re3">300px</span>;</p>
<p>&nbsp; &nbsp; <span class="kw1">z-index</span>: <span class="nu0">1</span>;<br />
&nbsp; <span class="br0">&#125;</span></div>
<p>Ok, now that the backend is all there, we need to do the difficult part (probably the easy bit for everyone else!), making the HTML page.</p>
<div class="dean_ch" style="white-space: wrap;">
&lt;p id=&quot;navigation&quot;&gt;</p>
<p>&lt;span style=&quot;cursor: pointer&quot; onclick=&quot;loadContent(1);&quot;&gt;Load Content 1&lt;/span&gt;<br />
&nbsp; &nbsp; &lt;span style=&quot;cursor: pointer&quot; onclick=&quot;loadContent(2);&quot;&gt;Load Content 2&lt;/span&gt;</p>
<p>&lt;!&#8211; Navigation End &#8211;&gt;<br />
&lt;p id=&quot;mainArea&quot;&gt; &lt;/p&gt;</p>
<p>&lt;p id=&quot;mainAreaInternal&quot; class=&quot;mainAreaInternal&quot;&gt;</p>
<p>This is the content that will be visible at the very beginning.</p>
<p>&lt;!&#8211; End Main Area Internal &#8211;&gt;</p>
<p>&lt;p id=&quot;mainAreaLoading&quot; class=&quot;mainAreaLoading&quot; style=&quot;display: none&quot;&gt;</p>
<p>&lt;span style=&quot;position: relative; top: 100px; left: 100px&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Loading Please Wait&#8230;<br />
&nbsp; &nbsp; &nbsp; &lt;/span&gt;</p>
<p>&lt;!&#8211; End Main Area &#8211;&gt;</p></div>
<p><strong>Now for the little explaination</strong><br />
Basically the loading &#8216;div&#8217; area is always there, it is just hidden from view, so when you call the &#8217;startLoading()&#8217; function it shows it, then hides it after the allotted time.<br />
Adding new &#8216;cases&#8217; to the rpc.php file will allow more content to be loaded <img src='http://www.nodstrum.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Example and Code</strong><br />
<a href="http://nodstrum.com/wp-content/plugins/DownloadCounter/download.php?id=17">Content Loading Example</a><br />
<a href="http://nodstrum.com/wp-content/plugins/DownloadCounter/download.php?id=18">RPC.php Source Code</a></p>
<p><a href="http://nodstrum.com/wp-content/plugins/DownloadCounter/download.php?id=24" title="Get the Full Code in a ZIP Here">Get the Full Code in  a ZIP Here. </a></p>
<p>&#8211; If you are using this script, i would greatly appreciate it if you referenced http://nodstrum.com in your sourcecode <img src='http://www.nodstrum.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  &#8211;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nodstrum.com/2007/02/27/ajaxcontentload/feed/</wfw:commentRss>
		<slash:comments>133</slash:comments>
		</item>
		<item>
		<title>Image Manipulation using PHP and ImageMagicK</title>
		<link>http://www.nodstrum.com/2007/02/06/imagemagick_manipulation/</link>
		<comments>http://www.nodstrum.com/2007/02/06/imagemagick_manipulation/#comments</comments>
		<pubDate>Tue, 06 Feb 2007 17:46:06 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://nodstrum.com/2007/02/06/imagemagick_manipulation/</guid>
		<description><![CDATA[So there were a couple of problems with my last image processing functions (http://nodstrum.com/2006/12/09/image-manipulation-using-php/).
1. If you were trying to process a massive image &#62; 1024pxÃ—768px it failed.
2. I only accounted for people processing Jpegs.
3. CPU spikes, because of the amount of processing that is being done with the image the CPU is really taking a [...]]]></description>
			<content:encoded><![CDATA[<p>So there were a couple of problems with my last image processing functions (<a href="http://nodstrum.com/2006/12/09/image-manipulation-using-php/">http://nodstrum.com/2006/12/09/image-manipulation-using-php/</a>).</p>
<p>1. If you were trying to process a massive image &gt; 1024pxÃ—768px it failed.<br />
2. I only accounted for people processing Jpegs.<br />
3. CPU spikes, because of the amount of processing that is being done with the image the CPU is really taking a hit.<br />
4. The functions were really quite long.</p>
<p>These new function will use ImageMagicK, not all servers have ImageMagicK installed by default, check with your hosting provider.</p>
<p><span id="more-17"></span></p>
<p>So, here are the functions&#8230;</p>
<p><strong>Thumbnail</strong></p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw2">function</span> createThumbIMK<span class="br0">&#40;</span><span class="re0">$img</span>, <span class="re0">$imgPath</span>, <span class="re0">$thumbDir</span>, <span class="re0">$suffix</span>, <span class="re0">$newWidth</span>, <span class="re0">$newHeight</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// add in the suffix after the &#8216;.&#8217; dot.</span><br />
&nbsp; <span class="re0">$newNameE</span> = <a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st0">&quot;.&quot;</span>, <span class="re0">$img</span><span class="br0">&#41;</span>;<br />
&nbsp; <span class="re0">$newName</span> = <span class="st0">&#8221;</span>. <span class="re0">$newNameE</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> .<span class="st0">&#8221;</span>. <span class="re0">$suffix</span> .<span class="st0">&#8216;.&#8217;</span>. <span class="re0">$newNameE</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span> .<span class="st0">&#8221;</span>;</p>
<p>&nbsp; <span class="co1">// ImageMagicK doesnt like &#8216;/&#8217; and &#8216;x&#8217; characters in the command line call.</span><br />
&nbsp; <span class="re0">$uploadedImg</span> = <span class="st0">&#8221;</span>. <span class="re0">$imgPath</span> .<span class="st0">&#8216;/&#8217;</span>. <span class="re0">$img</span> .<span class="st0">&#8221;</span>;<br />
&nbsp; <span class="re0">$newThumb</span> = <span class="st0">&#8221;</span>. <span class="re0">$thumbDir</span> .<span class="st0">&#8216;/&#8217;</span>. <span class="re0">$newName</span> .<span class="st0">&#8221;</span>;<br />
&nbsp; <span class="re0">$newRes</span> = <span class="st0">&#8221;</span>. <span class="re0">$newWidth</span> .<span class="st0">&#8216;x&#8217;</span>. <span class="re0">$newHeight</span> .<span class="st0">&#8221;</span>;</p>
<p>&nbsp; <span class="co1">// This makes a command line call to ImageMagicK.</span><br />
&nbsp; <span class="co1">// My path to ImageMagicK Convert is &#8216;/usr/lib/php/bin/convert&#8217;</span><br />
&nbsp; <span class="co1">// &#8216;convert&#8217; is a program (UNIX) so no forward slash.</span><br />
&nbsp; <span class="re0">$ct</span> = <a href="http://www.php.net/system"><span class="kw3">system</span></a><span class="br0">&#40;</span><span class="st0">&quot;/usr/lib/php/bin/convert -resize $newRes $uploadedImg $newThumb&quot;</span>, <span class="re0">$retval</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; <span class="kw1">return</span> <span class="re0">$ct</span>;<br />
<span class="br0">&#125;</span></div>
<p><strong>Resize</strong></p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw2">function</span> createResizedIMK<span class="br0">&#40;</span><span class="re0">$img</span>, <span class="re0">$imgPath</span>, <span class="re0">$thumbDir</span>, <span class="re0">$suffix</span>, <span class="re0">$by</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// add in the suffix after the &#8216;.&#8217; dot.</span><br />
&nbsp; <span class="re0">$newNameE</span> = <a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st0">&quot;.&quot;</span>, <span class="re0">$img</span><span class="br0">&#41;</span>;<br />
&nbsp; <span class="re0">$newName</span> = <span class="st0">&#8221;</span>. <span class="re0">$newNameE</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> .<span class="st0">&#8221;</span>. <span class="re0">$suffix</span> .<span class="st0">&#8216;.&#8217;</span>. <span class="re0">$newNameE</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span> .<span class="st0">&#8221;</span>;</p>
<p>&nbsp; <span class="co1">// ImageMagicK doesnt like &#8216;/&#8217; and &#8216;x&#8217; characters in the command line call.</span><br />
&nbsp; <span class="co1">// And workout the size based on &#8216;$by&#8217;.</span><br />
&nbsp; <span class="re0">$uploadedImg</span> = <span class="st0">&#8221;</span>. <span class="re0">$imgPath</span> .<span class="st0">&#8216;/&#8217;</span>. <span class="re0">$img</span> .<span class="st0">&#8221;</span>;<br />
&nbsp; <span class="re0">$newResized</span> = <span class="st0">&#8221;</span>. <span class="re0">$reduceDir</span> .<span class="st0">&#8216;/&#8217;</span>. <span class="re0">$newName</span> .<span class="st0">&#8221;</span>;<br />
&nbsp; <a href="http://www.php.net/list"><span class="kw3">list</span></a><span class="br0">&#40;</span><span class="re0">$width</span>, <span class="re0">$height</span>, <span class="re0">$type</span>, <span class="re0">$attr</span><span class="br0">&#41;</span> = <a href="http://www.php.net/getimagesize"><span class="kw3">getimagesize</span></a><span class="br0">&#40;</span><span class="st0">&quot;$imgPath/$img&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; <span class="re0">$newWidth</span> = <span class="br0">&#40;</span><span class="re0">$width</span>/<span class="re0">$by</span><span class="br0">&#41;</span>;<br />
&nbsp; <span class="re0">$newHeight</span> = <span class="br0">&#40;</span><span class="re0">$height</span>/<span class="re0">$by</span><span class="br0">&#41;</span>;<br />
&nbsp; <span class="re0">$newRes</span> = <span class="st0">&#8221;</span>. <span class="re0">$newWidth</span> .<span class="st0">&#8216;x&#8217;</span>. <span class="re0">$newHeight</span> .<span class="st0">&#8221;</span>;</p>
<p>&nbsp; <span class="co1">// This makes a command line call to ImageMagicK.</span><br />
&nbsp; <span class="co1">// My path to ImageMagicK Convert is &#8216;/usr/lib/php/bin/convert&#8217;</span><br />
&nbsp; <span class="co1">// &#8216;convert&#8217; is a program (UNIX) so no forward slash.</span><br />
&nbsp; <span class="re0">$cr</span> = <a href="http://www.php.net/system"><span class="kw3">system</span></a><span class="br0">&#40;</span><span class="st0">&quot;/usr/lib/php/bin/convert -resize $newRes $uploadedImg $newResized&quot;</span>, <span class="re0">$retval</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; <span class="kw1">return</span> <span class="re0">$cr</span>;<br />
<span class="br0">&#125;</span></div>
<p>!! <strong>Important:</strong> you must ensure that when you pass $img to the functions that it has no spaces in it&#8230; here is an example (replacing spaced with &#8216;_&#8217; underscores. Also dont forget to rename the actual file. !!</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="re0">$imgSafe</span> = <a href="http://www.php.net/str_replace"><span class="kw3">str_replace</span></a><span class="br0">&#40;</span><span class="st0">&quot; &quot;</span>, <span class="st0">&quot;_&quot;</span>, <span class="re0">$img</span><span class="br0">&#41;</span>;<br />
<a href="http://www.php.net/rename"><span class="kw3">rename</span></a><span class="br0">&#40;</span><span class="st0">&quot;$dir/$img&quot;</span>, <span class="st0">&quot;$dir/$imgSafe&quot;</span><span class="br0">&#41;</span>;</div>
<p>Here are some examples.<br />
<a href="http://nodstrum.com/wp-content/plugins/DownloadCounter/download.php?id=14">Building Original (916K (2576&#215;1932))</a><br />
<a href="http://nodstrum.com/wp-content/plugins/DownloadCounter/download.php?id=15">Building Thumb (20K (120&#215;90))</a><br />
<a href="http://nodstrum.com/wp-content/plugins/DownloadCounter/download.php?id=16">Building Resized and Reduced (71K (515&#215;386))</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nodstrum.com/2007/02/06/imagemagick_manipulation/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Transparency in IE6 and Other Browsers :)</title>
		<link>http://www.nodstrum.com/2007/02/02/csstransparency/</link>
		<comments>http://www.nodstrum.com/2007/02/02/csstransparency/#comments</comments>
		<pubDate>Fri, 02 Feb 2007 10:06:44 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Dev]]></category>

		<guid isPermaLink="false">http://nodstrum.com/2007/02/02/csstransparency/</guid>
		<description><![CDATA[This post will cover backgrounds (for DIVs) and transparent images (.PNGs)
As we ALL know; IE6 poses far too many challenges for designers, resulting in seperate stylesheets and hacks.
I found the need for a transparent background with links on top of it, in Firefox &#38; Safari (and IE7) PNGs are supported, so all worked fine, but [...]]]></description>
			<content:encoded><![CDATA[<p>This post will cover backgrounds (for DIVs) and transparent images (.PNGs)</p>
<p>As we ALL know; IE6 poses far too many challenges for designers, resulting in seperate stylesheets and hacks.<br />
I found the need for a transparent background with links on top of it, in Firefox &amp; Safari (and IE7) PNGs are supported, so all worked fine, but when tried with IE6, Yea, there were PROBLEMS! No PNG support and links within the transparent window disappeared.</p>
<p><strong>There are links to the PNGs and Demos at the bottom of the post.</strong></p>
<p>This is the difinitive way to make transparency work with all browsers!</p>
<p><span id="more-14"></span></p>
<p><strong>CSS code for STANDARD supporting browsers (Firefox, Safari).</strong></p>
<div class="dean_ch" style="white-space: wrap;">
<span class="re1">.transparent</span> <span class="br0">&#123;</span><br />
<span class="kw1">position</span>: <span class="kw2">absolute</span>;<br />
<span class="kw1">top</span>: <span class="re3">10px</span>;<br />
<span class="kw1">left</span>: <span class="re3">10px</span>;<br />
<span class="kw1">width</span>: <span class="re3">200px</span>;<br />
<span class="kw1">height</span>: <span class="re3">250px</span>;<br />
<span class="kw1">border</span>: <span class="re3">1px</span> <span class="kw2">solid</span> <span class="re0">#<span class="nu0">000</span></span>;</p>
<p><span class="kw1">background</span>: <span class="kw2">url</span><span class="br0">&#40;</span><span class="st0">&#8216;../images/blackTransparent80.png&#8217;</span><span class="br0">&#41;</span>;</p>
<p><span class="kw1">z-index</span>: <span class="nu0">1</span>;<br />
<span class="br0">&#125;</span></div>
<p><strong>CSS code for IE6 (hack).</strong> this is put in the style-sheet as well.<br />
(The &#8216;*html&#8217; only works on IE and is ignored by all other browsers.)</p>
<div class="dean_ch" style="white-space: wrap;">*html <span class="re1">.transparent</span> <span class="br0">&#123;</span><br />
<span class="kw1">position</span>: <span class="kw2">absolute</span>;<br />
<span class="kw1">top</span>: <span class="re3">10px</span>;<br />
<span class="kw1">left</span>: <span class="re3">10px</span>;<br />
<span class="kw1">width</span>: <span class="re3">200px</span>;<br />
<span class="kw1">height</span>: <span class="re3">250px</span>;<br />
<span class="kw1">border</span>: <span class="re3">1px</span> <span class="kw2">solid</span> <span class="re0">#<span class="nu0">000</span></span>;</p>
<p><span class="kw1">background</span>: <span class="kw2">none</span>;<br />
filter<span class="re2">:progid</span><span class="re2"> <img src='http://www.nodstrum.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> XImageTransform</span><span class="re1">.Microsoft</span><span class="re1">.AlphaImageLoader</span><span class="br0">&#40;</span>src=<span class="st0">&#8216;images/blackTransparent80.png&#8217;</span>, sizingMethod=<span class="st0">&#8217;scale&#8217;</span><span class="br0">&#41;</span>;</p>
<p><span class="kw1">z-index</span>: <span class="nu0">1</span>;<br />
<span class="br0">&#125;</span></div>
<p><strong>This code is the code for the DIV</strong></p>
<div class="dean_ch" style="white-space: wrap;">
&lt;p class=&quot;transparent&quot;&gt;<br />
&lt;span style=&quot;position: relative; top: 1px; left: 1px&quot;&gt;<br />
&lt;a href=&quot;http://nodstrum.com&quot;&gt;nodstrum.com&lt;/a&gt;<br />
&lt;/span&gt;<br />
&lt;span style=&quot;position: relative; top: 90px; left: 270px&quot;&gt;<br />
&lt;a href=&quot;http://blue44.com&quot;&gt;blue44.com&lt;/a&gt;<br />
&lt;/span&gt;<br />
&lt;span style=&quot;position: relative; top: 200px; left: 70px&quot;&gt;<br />
&lt;a href=&quot;http://teenfirst.com&quot;&gt;teenfirst.com&lt;/a&gt;<br />
&lt;/span&gt;</div>
<p>Here are the links to my pre-made transparent backgrounds and the demos.<br />
<a href="http://nodstrum.com/wp-content/plugins/DownloadCounter/download.php?id=10">Transparency Demo &#8211; White</a><br />
<a href="http://nodstrum.com/wp-content/plugins/DownloadCounter/download.php?id=11">Transparency Demo &#8211; Black</a><br />
<a href="http://nodstrum.com/wp-content/plugins/DownloadCounter/download.php?id=13">White 80% Transparent PNG (1px x 1px)</a><br />
<a href="http://nodstrum.com/wp-content/plugins/DownloadCounter/download.php?id=12">Black 80% Transparent PNG (1px x 1px)</a></p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nodstrum.com/2007/02/02/csstransparency/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Calendar System &#8211; Easily using PHP &amp; Script.aculo.us</title>
		<link>http://www.nodstrum.com/2007/01/29/phpcalendar/</link>
		<comments>http://www.nodstrum.com/2007/01/29/phpcalendar/#comments</comments>
		<pubDate>Mon, 29 Jan 2007 21:37:48 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://nodstrum.com/2007/01/29/phpcalendar/</guid>
		<description><![CDATA[THIS HAS BEEN UPDATED, PLEASE SEE THIS POST: http://nodstrum.com/2007/06/27/mysql-calendar/ 
Hi,
Quite a few people seemed to like my previous tutorial Image Manipulation using PHP, and looking around many of the tutorial sites there are hardly any Calendar systems. Perfect, here is a simple, in calendar terms one&#8230;
You&#8217;ll see what i mean.
At the bottom of this tutorial [...]]]></description>
			<content:encoded><![CDATA[<p><strong>THIS HAS BEEN UPDATED, PLEASE SEE THIS POST: <a href="http://nodstrum.com/2007/06/27/mysql-calendar/">http://nodstrum.com/2007/06/27/mysql-calendar/</a></strong><a href="http://nodstrum.com/2007/06/27/mysql-calendar/"> </a></p>
<p>Hi,</p>
<p>Quite a few people seemed to like my previous tutorial <a href="http://nodstrum.com/2006/12/09/image-manipulation-using-php/">Image Manipulation using PHP</a>, and looking around many of the tutorial sites there are hardly any Calendar systems. Perfect, here is a simple, in calendar terms one&#8230;<br />
You&#8217;ll see what i mean.</p>
<p><strong>At the bottom of this tutorial there is a link to the ZIP and the test site. </strong></p>
<p>There are 3 main parts, the Javascript, the HTML and the PHP script.<br />
For this tutorial i am making it so you can change the date with the form and it will update the calendar without having to reload the entire page, AJAX style.</p>
<p>First we need the Script.aculo.us library, if you download my zip test file it is already included, but if not go to: http://script.aculo.us</p>
<p><span id="more-16"></span></p>
<p>This is the basic HTML page with the style sheet.<br />
The stylesheet is important because it contains the .calendarFloat part.<br />
The important part is the &lt; div id=&#8221;calendarInternal&#8221; &gt; this is where the calendar will be loaded into, its in its own &lt; div &gt; because we need to clear the float to enclose the calendar and make the box enclose the entire calendar.</p>
<div class="dean_ch" style="white-space: wrap;">
<p>&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot; /&gt;<br />
&lt;script src=&quot;js/lib/prototype.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;<br />
&lt;script src=&quot;js/src/scriptaculous.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;<br />
&lt;style&gt;<br />
&nbsp; .calendarBox {<br />
&nbsp; &nbsp; position: relative;<br />
&nbsp; &nbsp; top: 30px;<br />
&nbsp; &nbsp; margin: 0 auto;<br />
&nbsp; &nbsp; padding: 5px;<br />
&nbsp; &nbsp; width: 254px;<br />
&nbsp; &nbsp; border: 1px solid #000;<br />
&nbsp; }</p>
<p>&nbsp; .calendarFloat {<br />
&nbsp; &nbsp; float: left;<br />
&nbsp; &nbsp; width: 31px;<br />
&nbsp; &nbsp; height: 25px;<br />
&nbsp; &nbsp; margin: 1px 0px 0px 1px;<br />
&nbsp; &nbsp; padding: 1px;<br />
&nbsp; &nbsp; border: 1px solid #000;<br />
&nbsp; }<br />
&lt;/style&gt;<br />
&lt;p id=&quot;calendar&quot; class=&quot;calendarBox&quot;&gt; &lt;/p&gt;</p>
<p>&lt;p id=&quot;calendarInternal&quot;&gt;</p>
<p>&lt;br style=&quot;clear: both&quot; /&gt;</p></div>
<p>Next is the Javascript that has to be added to the Head of the document.<br />
This does the highlighting and loading of the calendar using the script.aculo.us</p>
<div class="dean_ch" style="white-space: wrap;">
&lt;script type=<span class="st0">&quot;text/javascript&quot;</span>&gt;<br />
&nbsp; <span class="kw2">function</span> highlightCalendarCell<span class="br0">&#40;</span>element<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; $<span class="br0">&#40;</span>element<span class="br0">&#41;</span>.<span class="me1">style</span>.<span class="me1">border</span> = <span class="st0">&#8216;1px solid #999999&#8242;</span>;<br />
&nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; <span class="kw2">function</span> resetCalendarCell<span class="br0">&#40;</span>element, color<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; $<span class="br0">&#40;</span>element<span class="br0">&#41;</span>.<span class="me1">style</span>.<span class="me1">border</span> = <span class="st0">&#8216;1px solid #000000&#8242;</span>;<br />
&nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; <span class="kw2">function</span> startCalendar<span class="br0">&#40;</span>month, year<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="kw2">new</span> Ajax.<span class="me1">Updater</span><span class="br0">&#40;</span><span class="st0">&#8216;calendarInternal&#8217;</span>, <span class="st0">&#8216;rpc.php&#8217;</span>, <span class="br0">&#123;</span>method: <span class="st0">&#8216;post&#8217;</span>, postBody:<span class="st0">&#8216;action=startCalendar&amp;month=&#8217;</span>+month+<span class="st0">&#8216;&amp;year=&#8217;</span>+year+<span class="st0">&#8221;</span><span class="br0">&#125;</span><span class="br0">&#41;</span>;<br />
&nbsp; <span class="br0">&#125;</span><br />
&lt;/script&gt;</div>
<p>The 2nd to last part is the RPC page, its not truly an RPC (remote procedure call) page, i just call it that because it is distinct.<br />
I use a switch statement because my function is normally enclosed in a huge page, so here goes.</p>
<div class="dean_ch" style="white-space: wrap;">
<p>&nbsp; <span class="re0">$action</span> = <span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st0">&#8216;action&#8217;</span><span class="br0">&#93;</span>;<br />
&nbsp; <span class="kw1">switch</span><span class="br0">&#40;</span><span class="re0">$action</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></p>
<p>&nbsp; <span class="kw1">case</span> <span class="st0">&#8217;startCalendar&#8217;</span>:<br />
&nbsp; &nbsp; <span class="re0">$month</span> = <span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st0">&#8216;month&#8217;</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="re0">$year</span> = <span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st0">&#8216;year&#8217;</span><span class="br0">&#93;</span>;</p>
<p>&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="br0">&#40;</span><span class="re0">$month</span> == <span class="nu0">0</span><span class="br0">&#41;</span> || <span class="br0">&#40;</span><span class="re0">$year</span> == <span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">$thisDate</span> = <a href="http://www.php.net/mktime"><span class="kw3">mktime</span></a><span class="br0">&#40;</span><span class="nu0">0</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&quot;m&quot;</span><span class="br0">&#41;</span>, <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&quot;d&quot;</span><span class="br0">&#41;</span>, <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&quot;Y&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">$thisDate</span> = <a href="http://www.php.net/mktime"><span class="kw3">mktime</span></a><span class="br0">&#40;</span><span class="nu0">0</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <span class="re0">$month</span>, <span class="nu0">1</span>, <span class="re0">$year</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;<br />
&lt;p style=&quot;margin-bottom: 3px&quot;&gt; &lt;/p&gt;</p>
<p>&lt;form name=&quot;changeCalendarDate&quot;&gt;<br />
&lt;select id=&quot;ccMonth&quot; onchange=&quot;startCalendar($F(&#8216;</span>ccMonth<span class="st0">&#8216;), $F(&#8216;</span>ccYear<span class="st0">&#8216;))&quot;&gt;&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; &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; &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; &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; &nbsp; &nbsp; &nbsp; &lt;option value=&quot;&#8217;</span>. <span class="re0">$i</span> .<span class="st0">&#8216;&quot;&gt;&#8217;</span>. <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&quot;F&quot;</span>, <span class="re0">$monthMaker</span><span class="br0">&#41;</span> .<span class="st0">&#8216;&lt;/option&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/select&gt;<br />
&lt;select id=&quot;ccYear&quot; onchange=&quot;startCalendar($F(&#8216;</span>ccMonth<span class="st0">&#8216;), $F(&#8216;</span>ccYear<span class="st0">&#8216;))&quot;&gt;&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; &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; &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; &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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option value=&quot;&#8217;</span>. <span class="re0">$i</span> .<span class="st0">&#8216;&quot;&gt;&#8217;</span>. <span class="re0">$i</span> .<span class="st0">&#8216;&lt;/option&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/select&gt;<br />
&lt;/form&gt;</p>
<p>&#8216;</span>;</p>
<p>&nbsp; &nbsp; <span class="co1">// Display the week days.</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;<br />
&lt;p class=&quot;calendarFloat&quot; style=&quot;text-align: center; background-color: #f0f2ff&quot;&gt;&lt;span style=&quot;position: relative; top: 4px&quot;&gt;Mon&lt;/span&gt;&lt;/p&gt;<br />
&lt;p class=&quot;calendarFloat&quot; style=&quot;text-align: center; background-color: #f0f2ff&quot;&gt;&lt;span style=&quot;position: relative; top: 4px&quot;&gt;Tue&lt;/span&gt;&lt;/p&gt;<br />
&lt;p class=&quot;calendarFloat&quot; style=&quot;text-align: center; background-color: #f0f2ff&quot;&gt;&lt;span style=&quot;position: relative; top: 4px&quot;&gt;Wed&lt;/span&gt;&lt;/p&gt;<br />
&lt;p class=&quot;calendarFloat&quot; style=&quot;text-align: center; background-color: #f0f2ff&quot;&gt;&lt;span style=&quot;position: relative; top: 4px&quot;&gt;Thur&lt;/span&gt;&lt;/p&gt;<br />
&lt;p class=&quot;calendarFloat&quot; style=&quot;text-align: center; background-color: #f0f2ff&quot;&gt;&lt;span style=&quot;position: relative; top: 4px&quot;&gt;Fri&lt;/span&gt;&lt;/p&gt;<br />
&lt;p class=&quot;calendarFloat&quot; style=&quot;text-align: center; background-color: #cccccc&quot;&gt;&lt;span style=&quot;position: relative; top: 4px&quot;&gt;Sat&lt;/span&gt;&lt;/p&gt;</p>
<p>&lt;p class=&quot;calendarFloat&quot; style=&quot;text-align: center; background-color: #cccccc&quot;&gt;&lt;span style=&quot;position: relative; top: 4px&quot;&gt;Sun&lt;/span&gt;</p>
<p>&#8216;</span>;</p>
<p>&nbsp; &nbsp; <span class="co1">// Show the calendar.</span><br />
&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;date<span class="br0">&#40;</span><span class="st0">&quot;t&quot;</span>,&gt;<br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">$thisDay</span> = <span class="br0">&#40;</span><span class="re0">$i</span> + <span class="nu0">1</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="br0">&#40;</span><span class="re0">$month</span> == <span class="nu0">0</span><span class="br0">&#41;</span> || <span class="br0">&#40;</span><span class="re0">$year</span> == <span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$finalDate</span> = <a href="http://www.php.net/mktime"><span class="kw3">mktime</span></a><span class="br0">&#40;</span><span class="nu0">0</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&quot;m&quot;</span><span class="br0">&#41;</span>, <span class="re0">$thisDay</span>, <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&quot;Y&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$today</span> = <a href="http://www.php.net/mktime"><span class="kw3">mktime</span></a><span class="br0">&#40;</span><span class="nu0">0</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&quot;m&quot;</span><span class="br0">&#41;</span>, <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&quot;d&quot;</span><span class="br0">&#41;</span>, <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&quot;Y&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$fdf</span> = <a href="http://www.php.net/mktime"><span class="kw3">mktime</span></a><span class="br0">&#40;</span><span class="nu0">0</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&quot;m&quot;</span><span class="br0">&#41;</span>, <span class="nu0">1</span>, <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&quot;Y&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$month</span> = <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&quot;m&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$year</span> = <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&quot;Y&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$finalDate</span> = <a href="http://www.php.net/mktime"><span class="kw3">mktime</span></a><span class="br0">&#40;</span><span class="nu0">0</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <span class="re0">$month</span>, <span class="re0">$thisDay</span>, <span class="re0">$year</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$fdf</span> = <a href="http://www.php.net/mktime"><span class="kw3">mktime</span></a><span class="br0">&#40;</span><span class="nu0">0</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <span class="re0">$month</span>, <span class="nu0">1</span>, <span class="re0">$year</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; <span class="co1">// Skip some cells to take into account for the weekdays.</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$i</span> == <span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$firstDay</span> = <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&quot;w&quot;</span>, <span class="re0">$fdf</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$skip</span> = <span class="br0">&#40;</span><span class="re0">$firstDay</span> &#8211; <span class="nu0">1</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$skip</span> &lt; <span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$skip</span> = <span class="nu0">6</span>; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span><span class="br0">&#40;</span><span class="re0">$s</span>=<span class="nu0">0</span>; <span class="re0">$s</span>&lt;<span class="re0">$skip</span>; <span class="re0">$s</span>++<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;<br />
&lt;/date(&quot;t&quot;,&gt;</p>
<p>&lt;p class=&quot;calendarFloat&quot; style=&quot;border: 1px solid #ffffff&quot;&gt;</p>
<p>&#8216;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; <span class="co1">// Make the weekends a darker colour.</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="br0">&#40;</span><a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&quot;w&quot;</span>, <span class="re0">$finalDate</span><span class="br0">&#41;</span> == <span class="nu0">0</span><span class="br0">&#41;</span> || <span class="br0">&#40;</span><a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&quot;w&quot;</span>, <span class="re0">$finalDate</span><span class="br0">&#41;</span> == <span class="nu0">6</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$bgColor</span> = <span class="st0">&#8216;#CCC&#8217;</span>;<br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$bgColor</span> = <span class="st0">&#8216;#f0f2ff&#8217;</span>;<br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// == Add any database query here using $finalDate as the timestamp for this date.</span></p>
<p>&nbsp; &nbsp; &nbsp; <span class="co1">// Display the day.</span><br />
&nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;</p>
<p>&lt;p class=&quot;calendarFloat&quot; id=&quot;calendarDay_&#8217;</span>. <span class="re0">$thisDay</span> .<span class="st0">&#8216;&quot; style=&quot;cursor: pointer&quot;&gt;</p>
<p>onMouseOver=&quot;highlightCalendarCell(&#8216;</span>calendarDay_<span class="st0">&#8216;. $thisDay .&#8217;</span><span class="st0">&#8216;)&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onMouseOut=&quot;resetCalendarCell(&#8216;</span>calendarDay_<span class="st0">&#8216;. $thisDay .&#8217;</span><span class="st0">&#8216;)&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;span style=&quot;position: relative; left: 1px&quot;&gt;&#8217;</span>. <span class="re0">$thisDay</span> .<span class="st0">&#8216;&lt;/span&gt;</p>
<p>&#8216;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">break</span>;<br />
&nbsp; <span class="br0">&#125;</span></p>
<p><span class="kw2">?&gt;</span></div>
<p>The final part is the one that ties it all together. This javascript is placed at the bottom of the page, within the &lt; body &gt; tags.</p>
<div class="dean_ch" style="white-space: wrap;">
&lt;script type=<span class="st0">&quot;text/javascript&quot;</span>&gt;<br />
&nbsp; &nbsp; startCalendar<span class="br0">&#40;</span><span class="nu0">0</span>,<span class="nu0">0</span><span class="br0">&#41;</span>;<br />
&nbsp; &lt;/script&gt;</div>
<p>Now for a short explaniation&#8230;<br />
If startCalendar(0,0) is called like so, with zeros, it defaults to the current month, if you have a look at the RPC file, at the top, you will notice there is a line that is if $month == 0 and $year == 0, then the date is date(&#8220;m&#8221;); (i think).</p>
<p>Next we are making the form for selecting the month and year, at the same time making the selected month and year (gotten by $month and $year) the current ones in the drop doen boxes.</p>
<p>Now we are just displaying the days of the week so the calendar is readable.<br />
Now the difficult part, determining the timestamp incase we want to use the database.<br />
Skipping some days to take into account days from the previous month, so the 1st of the month starts ont he proper week day, thats a tough one.<br />
Then its just spitting out the calendar.</p>
<p>And here is the Piece De Resistance, if you can call it that&#8230;<br />
<a href="http://res.nodstrum.com/calendar/" target="_blank">http://res.nodstrum.com/calendar/</a></p>
<p>And now for the downloads:<br />
<a href="http://nodstrum.com/wp-content/plugins/DownloadCounter/download.php?id=6">Calendar System ZIP</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nodstrum.com/2007/01/29/phpcalendar/feed/</wfw:commentRss>
		<slash:comments>45</slash:comments>
		</item>
		<item>
		<title>Image Manipulation using PHP</title>
		<link>http://www.nodstrum.com/2006/12/09/image-manipulation-using-php/</link>
		<comments>http://www.nodstrum.com/2006/12/09/image-manipulation-using-php/#comments</comments>
		<pubDate>Sat, 09 Dec 2006 14:24:57 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://nodstrum.com/2006/12/09/image-manipulation-using-php/</guid>
		<description><![CDATA[I have been trawling around the internet looking for some simple functions for do basic automated manipulation to some images im using.
if you want to skip straight to the examples just to prove im not bulls**ting skip to the bottom
Basically i wanted to have these functions:
1. thumbnail
2. resize (actual image)
3. reduce (image file size)
4. rotate [...]]]></description>
			<content:encoded><![CDATA[<p>I have been trawling around the internet looking for some simple functions for do basic automated manipulation to some images im using.</p>
<p><strong>if you want to skip straight to the examples just to prove im not bulls**ting skip to the bottom</strong></p>
<p>Basically i wanted to have these functions:<br />
1. <strong>thumbnail</strong><br />
2. <strong>resize (actual image)</strong><br />
3. <strong>reduce (image file size)</strong><br />
4. <strong>rotate (by degrees)</strong></p>
<p>Most of the scripts i found couldnt be changed easily to make them do what i wanted&#8230;<br />
So here are what i got working.. and a few instructions&#8230;</p>
<p><span id="more-7"></span></p>
<p><strong>Create a thumbnail</strong></p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw2">function</span> createThumbnail<span class="br0">&#40;</span><span class="re0">$img</span>, <span class="re0">$imgPath</span>, <span class="re0">$suffix</span>, <span class="re0">$newWidth</span>, <span class="re0">$newHeight</span>, <span class="re0">$quality</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// Open the original image.</span><br />
&nbsp; <span class="re0">$original</span> = imagecreatefromjpeg<span class="br0">&#40;</span><span class="st0">&quot;$imgPath/$img&quot;</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&quot;Error Opening original&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; <a href="http://www.php.net/list"><span class="kw3">list</span></a><span class="br0">&#40;</span><span class="re0">$width</span>, <span class="re0">$height</span>, <span class="re0">$type</span>, <span class="re0">$attr</span><span class="br0">&#41;</span> = <a href="http://www.php.net/getimagesize"><span class="kw3">getimagesize</span></a><span class="br0">&#40;</span><span class="st0">&quot;$imgPath/$img&quot;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; <span class="co1">// Resample the image.</span><br />
&nbsp; <span class="re0">$tempImg</span> = imagecreatetruecolor<span class="br0">&#40;</span><span class="re0">$newWidth</span>, <span class="re0">$newHeight</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&quot;Cant create temp image&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; imagecopyresized<span class="br0">&#40;</span><span class="re0">$tempImg</span>, <span class="re0">$original</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <span class="re0">$newWidth</span>, <span class="re0">$newHeight</span>, <span class="re0">$width</span>, <span class="re0">$height</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&quot;Cant resize copy&quot;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; <span class="co1">// Create the new file name.</span><br />
&nbsp; <span class="re0">$newNameE</span> = <a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st0">&quot;.&quot;</span>, <span class="re0">$img</span><span class="br0">&#41;</span>;<br />
&nbsp; <span class="re0">$newName</span> = <span class="st0">&#8221;</span>. <span class="re0">$newNameE</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> .<span class="st0">&#8221;</span>. <span class="re0">$suffix</span> .<span class="st0">&#8216;.&#8217;</span>. <span class="re0">$newNameE</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span> .<span class="st0">&#8221;</span>;</p>
<p>&nbsp; <span class="co1">// Save the image.</span><br />
&nbsp; imagejpeg<span class="br0">&#40;</span><span class="re0">$tempImg</span>, <span class="st0">&quot;$imgPath/$newName&quot;</span>, <span class="re0">$quality</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&quot;Cant save image&quot;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; <span class="co1">// Clean up.</span><br />
&nbsp; imagedestroy<span class="br0">&#40;</span><span class="re0">$original</span><span class="br0">&#41;</span>;<br />
&nbsp; imagedestroy<span class="br0">&#40;</span><span class="re0">$tempImg</span><span class="br0">&#41;</span>;<br />
&nbsp; <span class="kw1">return</span> <span class="kw2">true</span>;<br />
<span class="br0">&#125;</span><br />
<span class="kw2">?&gt;</span></div>
<p><strong>Rotate</strong></p>
<div class="dean_ch" style="white-space: wrap;">
<p><span class="kw2">function</span> rotateImage<span class="br0">&#40;</span><span class="re0">$img</span>, <span class="re0">$imgPath</span>, <span class="re0">$suffix</span>, <span class="re0">$degrees</span>, <span class="re0">$quality</span>, <span class="re0">$save</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co1">// Open the original image.</span><br />
&nbsp; &nbsp; <span class="re0">$original</span> = imagecreatefromjpeg<span class="br0">&#40;</span><span class="st0">&quot;$imgPath/$img&quot;</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&quot;Error Opening original&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <a href="http://www.php.net/list"><span class="kw3">list</span></a><span class="br0">&#40;</span><span class="re0">$width</span>, <span class="re0">$height</span>, <span class="re0">$type</span>, <span class="re0">$attr</span><span class="br0">&#41;</span> = <a href="http://www.php.net/getimagesize"><span class="kw3">getimagesize</span></a><span class="br0">&#40;</span><span class="st0">&quot;$imgPath/$img&quot;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; <span class="co1">// Resample the image.</span><br />
&nbsp; &nbsp; <span class="re0">$tempImg</span> = imagecreatetruecolor<span class="br0">&#40;</span><span class="re0">$width</span>, <span class="re0">$height</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&quot;Cant create temp image&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; imagecopyresized<span class="br0">&#40;</span><span class="re0">$tempImg</span>, <span class="re0">$original</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <span class="re0">$width</span>, <span class="re0">$height</span>, <span class="re0">$width</span>, <span class="re0">$height</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&quot;Cant resize copy&quot;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; <span class="co1">// Rotate the image.</span><br />
&nbsp; &nbsp; <span class="re0">$rotate</span> = imagerotate<span class="br0">&#40;</span><span class="re0">$original</span>, <span class="re0">$degrees</span>, <span class="nu0">0</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; <span class="co1">// Save.</span><br />
&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$save</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Create the new file name.</span><br />
&nbsp; &nbsp; <span class="re0">$newNameE</span> = <a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st0">&quot;.&quot;</span>, <span class="re0">$img</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="re0">$newName</span> = <span class="st0">&#8221;</span>. <span class="re0">$newNameE</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> .<span class="st0">&#8221;</span>. <span class="re0">$suffix</span> .<span class="st0">&#8216;.&#8217;</span>. <span class="re0">$newNameE</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span> .<span class="st0">&#8221;</span>;</p>
<p>&nbsp; &nbsp; <span class="co1">// Save the image.</span><br />
&nbsp; &nbsp; imagejpeg<span class="br0">&#40;</span><span class="re0">$rotate</span>, <span class="st0">&quot;$imgPath/$newName&quot;</span>, <span class="re0">$quality</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&quot;Cant save image&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; <span class="co1">// Clean up.</span><br />
&nbsp; &nbsp; imagedestroy<span class="br0">&#40;</span><span class="re0">$original</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; imagedestroy<span class="br0">&#40;</span><span class="re0">$tempImg</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">true</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw2">?&gt;</span></div>
<p><strong>Resize</strong></p>
<div class="dean_ch" style="white-space: wrap;">
<p><span class="kw2">function</span> resizeImage<span class="br0">&#40;</span><span class="re0">$img</span>, <span class="re0">$imgPath</span>, <span class="re0">$suffix</span>, <span class="re0">$by</span>, <span class="re0">$quality</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co1">// Open the original image.</span><br />
&nbsp; &nbsp; <span class="re0">$original</span> = imagecreatefromjpeg<span class="br0">&#40;</span><span class="st0">&quot;$imgPath/$img&quot;</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&quot;Error Opening original (&lt;em&gt;$imgPath/$img&lt;/em&gt;)&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <a href="http://www.php.net/list"><span class="kw3">list</span></a><span class="br0">&#40;</span><span class="re0">$width</span>, <span class="re0">$height</span>, <span class="re0">$type</span>, <span class="re0">$attr</span><span class="br0">&#41;</span> = <a href="http://www.php.net/getimagesize"><span class="kw3">getimagesize</span></a><span class="br0">&#40;</span><span class="st0">&quot;$imgPath/$img&quot;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; <span class="co1">// Determine new width and height.</span><br />
&nbsp; &nbsp; <span class="re0">$newWidth</span> = <span class="br0">&#40;</span><span class="re0">$width</span>/<span class="re0">$by</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="re0">$newHeight</span> = <span class="br0">&#40;</span><span class="re0">$height</span>/<span class="re0">$by</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; <span class="co1">// Resample the image.</span><br />
&nbsp; &nbsp; <span class="re0">$tempImg</span> = imagecreatetruecolor<span class="br0">&#40;</span><span class="re0">$newWidth</span>, <span class="re0">$newHeight</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&quot;Cant create temp image&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; imagecopyresized<span class="br0">&#40;</span><span class="re0">$tempImg</span>, <span class="re0">$original</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <span class="re0">$newWidth</span>, <span class="re0">$newHeight</span>, <span class="re0">$width</span>, <span class="re0">$height</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&quot;Cant resize copy&quot;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; <span class="co1">// Create the new file name.</span><br />
&nbsp; &nbsp; <span class="re0">$newNameE</span> = <a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st0">&quot;.&quot;</span>, <span class="re0">$img</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="re0">$newName</span> = <span class="st0">&#8221;</span>. <span class="re0">$newNameE</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> .<span class="st0">&#8221;</span>. <span class="re0">$suffix</span> .<span class="st0">&#8216;.&#8217;</span>. <span class="re0">$newNameE</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span> .<span class="st0">&#8221;</span>;</p>
<p>&nbsp; &nbsp; <span class="co1">// Save the image.</span><br />
&nbsp; &nbsp; imagejpeg<span class="br0">&#40;</span><span class="re0">$tempImg</span>, <span class="st0">&quot;$imgPath/$newName&quot;</span>, <span class="re0">$quality</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&quot;Cant save image&quot;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; <span class="co1">// Clean up.</span><br />
&nbsp; &nbsp; imagedestroy<span class="br0">&#40;</span><span class="re0">$original</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; imagedestroy<span class="br0">&#40;</span><span class="re0">$tempImg</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">true</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw2">?&gt;</span></div>
<p><strong>Reduce</strong></p>
<div class="dean_ch" style="white-space: wrap;">
<p><span class="kw2">function</span> reduceImage<span class="br0">&#40;</span><span class="re0">$img</span>, <span class="re0">$imgPath</span>, <span class="re0">$suffix</span>, <span class="re0">$quality</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co1">// Open the original image.</span><br />
&nbsp; &nbsp; <span class="re0">$original</span> = imagecreatefromjpeg<span class="br0">&#40;</span><span class="st0">&quot;$imgPath/$img&quot;</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&quot;Error Opening original (&lt;em&gt;$imgPath/$img&lt;/em&gt;)&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <a href="http://www.php.net/list"><span class="kw3">list</span></a><span class="br0">&#40;</span><span class="re0">$width</span>, <span class="re0">$height</span>, <span class="re0">$type</span>, <span class="re0">$attr</span><span class="br0">&#41;</span> = <a href="http://www.php.net/getimagesize"><span class="kw3">getimagesize</span></a><span class="br0">&#40;</span><span class="st0">&quot;$imgPath/$img&quot;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; <span class="co1">// Resample the image.</span><br />
&nbsp; &nbsp; <span class="re0">$tempImg</span> = imagecreatetruecolor<span class="br0">&#40;</span><span class="re0">$width</span>, <span class="re0">$height</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&quot;Cant create temp image&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; imagecopyresized<span class="br0">&#40;</span><span class="re0">$tempImg</span>, <span class="re0">$original</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <span class="re0">$width</span>, <span class="re0">$height</span>, <span class="re0">$width</span>, <span class="re0">$height</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&quot;Cant resize copy&quot;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; <span class="co1">// Create the new file name.</span><br />
&nbsp; &nbsp; <span class="re0">$newNameE</span> = <a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st0">&quot;.&quot;</span>, <span class="re0">$img</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="re0">$newName</span> = <span class="st0">&#8221;</span>. <span class="re0">$newNameE</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> .<span class="st0">&#8221;</span>. <span class="re0">$suffix</span> .<span class="st0">&#8216;.&#8217;</span>. <span class="re0">$newNameE</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span> .<span class="st0">&#8221;</span>;</p>
<p>&nbsp; &nbsp; <span class="co1">// Save the image.</span><br />
&nbsp; &nbsp; imagejpeg<span class="br0">&#40;</span><span class="re0">$tempImg</span>, <span class="st0">&quot;$imgPath/$newName&quot;</span>, <span class="re0">$quality</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&quot;Cant save image&quot;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; <span class="co1">// Clean up.</span><br />
&nbsp; &nbsp; imagedestroy<span class="br0">&#40;</span><span class="re0">$original</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; imagedestroy<span class="br0">&#40;</span><span class="re0">$tempImg</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">true</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw2">?&gt;</span></div>
<p><strong>The simple instructions I used for the examples</strong></p>
<div class="dean_ch" style="white-space: wrap;">
<span class="re0">$thumb</span> = createThumbnail<span class="br0">&#40;</span><span class="re0">$img</span>, <span class="re0">$imgPath</span>, <span class="st0">&quot;-thumb&quot;</span>, <span class="nu0">120</span>, <span class="nu0">100</span>, <span class="nu0">100</span><span class="br0">&#41;</span>;<br />
<span class="re0">$rotate</span> = rotateImage<span class="br0">&#40;</span><span class="re0">$img</span>, <span class="re0">$imgPath</span>, <span class="st0">&quot;-rotated&quot;</span>, <span class="nu0">270</span>, <span class="nu0">100</span>, <span class="nu0">1</span><span class="br0">&#41;</span>;<br />
<span class="re0">$resize</span> = resizeImage<span class="br0">&#40;</span><span class="re0">$img</span>, <span class="re0">$imgPath</span>, <span class="st0">&quot;-resized&quot;</span>, <span class="nu0">2</span>, <span class="nu0">100</span><span class="br0">&#41;</span>;<br />
<span class="re0">$reduce</span> = reduceImage<span class="br0">&#40;</span><span class="re0">$img</span>, <span class="re0">$imgPath</span>, <span class="st0">&quot;-reduced&quot;</span>, <span class="nu0">70</span><span class="br0">&#41;</span>;<br />
<span class="kw2">?&gt;</span></div>
<p>Those are the function calls i used to create the images linked to below.</p>
<p><strong>createThumbnail variables</strong><br />
image file<br />
image file path<br />
suffix to append to the name before the .jpg<br />
thumbnail width<br />
thumbnail height<br />
thumbnail quality</p>
<p><strong>rotateImage variables</strong><br />
image file<br />
image file path<br />
suffix to append to the name before the .jpg<br />
degrees to rotate (anticlockwise i think) by<br />
image quality<br />
save or not (if you wanted to output to a temp to preview, i dont use it, so leave as 1</p>
<p><strong>resize variables</strong><br />
image file<br />
image file path<br />
suffix to append to the name before the .jpg<br />
resize by (i used <strong>2</strong> which i thought was half.. not so hot on the maths)<br />
image quality</p>
<p><strong>reduce variables</strong><br />
image file<br />
image file path<br />
suffix to append to the name before the .jpg<br />
quality (100 best, 0 worst&#8230; Duhh).</p>
<p><strong>Here are the links to my examples</strong><br />
<a href="http://nodstrum.com/wp-content/plugins/DownloadCounter/download.php?id=7">Original File (904k (1840&#215;1232))</a><br />
<a href="http://nodstrum.com/wp-content/plugins/DownloadCounter/download.php?id=8">Thumbnail (16k (120&#215;100))</a><br />
<a href="http://nodstrum.com/wp-content/plugins/DownloadCounter/download.php?id=9">Resized and Reduced (24k (368&#215;246))</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nodstrum.com/2006/12/09/image-manipulation-using-php/feed/</wfw:commentRss>
		<slash:comments>48</slash:comments>
		</item>
	</channel>
</rss>
