<?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>Photogabble &#187; PHP</title>
	<atom:link href="http://photogabble.co.uk/category/php/feed" rel="self" type="application/rss+xml" />
	<link>http://photogabble.co.uk</link>
	<description>photoblog of simon dann</description>
	<lastBuildDate>Sun, 25 Dec 2011 14:19:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Tiny Javascript WYSIWYG Editor</title>
		<link>http://photogabble.co.uk/php/tiny-javascript-wysiwyg-editor.html</link>
		<comments>http://photogabble.co.uk/php/tiny-javascript-wysiwyg-editor.html#comments</comments>
		<pubDate>Tue, 06 Apr 2010 22:23:06 +0000</pubDate>
		<dc:creator>simon</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Tiny Editor]]></category>
		<category><![CDATA[wysiwyg]]></category>

		<guid isPermaLink="false">http://photogabble.co.uk/?p=3451</guid>
		<description><![CDATA[If you search google for &#8220;wysiwyg JavaScript&#8221; you will find many full feature &#8220;what you see is what you get&#8221; editors written in JavaScript and developed for use within html forms. However many of these have dependencies upon external libraries such as jQuery or simply have everything plus the kitchen sink included; if your developing [...]]]></description>
			<content:encoded><![CDATA[<p>If you search google for &#8220;wysiwyg JavaScript&#8221; you will find many full feature &#8220;what you see is what you get&#8221; editors written in JavaScript and developed for use within html forms. However many of these have dependencies upon external libraries such as jQuery or simply have everything plus the kitchen sink included; if your developing an online word processor this many not be much of a problem to you however within the recent development work I have been involved in I just needed a good quality WYSIWYG editor, written in JavaScript and with only the basic text formatting features included. I am still unsure how I stumbled upon <a href="http://www.leigeber.com/2010/02/javascript-wysiwyg-editor/">TinyEditor</a> by Leighber, however stumble I did and it has proven perfect for my simplistic needs while having a few more extensive features for future expansion only when required and best of all it is a stand-alone package!</p>
<p>Other WYSIWYG editors I discovered and tested during my hunt where the jQuery based <a title="JQYSIWYG at google code" href="http://code.google.com/p/jwysiwyg/">jwysiwyg project</a> and the more complex <a title="WYMEDITOR Home page" href="http://www.wymeditor.org/">wymeditor</a>. While these were too complex for my needs they do work quite well and I would recommend you give them a go before making your mind up.</p>
<p>The one problem I do I have with TinyEditor is the unfortunate lack of a paste from word feature, I am hoping that this does become included soon because it is the only additional feature that is a must with WYSIWYG HTML editors due to paste from word screwing your nicely formatted code up upon submit.</p>
]]></content:encoded>
			<wfw:commentRss>http://photogabble.co.uk/php/tiny-javascript-wysiwyg-editor.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to cut down wordpress memory usage.</title>
		<link>http://photogabble.co.uk/php/how-to-cut-down-wordpress-memory-usage.html</link>
		<comments>http://photogabble.co.uk/php/how-to-cut-down-wordpress-memory-usage.html#comments</comments>
		<pubDate>Tue, 11 Aug 2009 15:35:34 +0000</pubDate>
		<dc:creator>simon</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[apc]]></category>
		<category><![CDATA[memory use]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://photogabble.co.uk/?p=2336</guid>
		<description><![CDATA[Photogabble is similar to many other websites in that it is managed via an installation of word-press; word-press by and large is a very good blogging platform, indeed I would say it is one of &#8211; if not &#8211; thee best blogging platform available today quite simply for its simplicity, its script-ability and ease of [...]]]></description>
			<content:encoded><![CDATA[<p>Photogabble is similar to many other websites in that it is managed via an installation of word-press; word-press by and large is a very good blogging platform, indeed I would say it is one of &#8211; if not &#8211; <em>thee</em> best blogging platform available today quite simply for its simplicity, its script-ability and ease of designing for. However there is one draw back, as with everything around us, wordpress is not perfect; indeed the average install alongside its additional plug-ins and add-ons seems to consume copious amounts of system memory which is <strong>bad</strong>! While I am lucky to have built my server from scratch it still has limitations the most important of which being memory, a whole 2GB of it.</p>
<p>Up until I completed the following quick fix, wordpress was using almost 30MB per instance, this means that I could only at peak have 66 or so visitors at the same time before my server became overrun and hid under the bed. What I needed to do was supercharge php and the easiest way to do that is by caching. Thanks to <a href="http://itst.net/654-php-on-fire-three-opcode-caches-compared">this interesting article</a> on php caching by itst.net I chose <a href="http://pecl.php.net/package/APC">APC </a>(Alternative PHP Cache) which is supported by the php foundation and showed the most promising speed improvements.</p>
<p>Installing APC really couldn&#8217;t have been made any easier on debian; it does require some dependencies, obviously php 5.x plus the pear package installed but apart from that not much else is needed to be installed and it you use apt-get they are installed as part of the installation process. The instillation process is as simple as follows:<br />
<code>
<pre>apt-get install php-apc
<br/>
/etc/init.d/apache2 restart</pre>
<p></code><br />
Once APC has been installed and apache restarted you can issue the following command to ensure that it has installed correctly:</p>
<pre><code>php -r 'phpinfo();' | grep apc</code></pre>
<p>Once that has been done and you get a positive response to the above command you should see that wordpress is using considerably less memory. My install with its 16 or so plugins now uses 3.16MB rather than almost 30MB! That is what you call a good improvement.</p>
<p>One draw back with apc as with many caching processes is that it does cause an initial increased draw on the processor while it compiles the php into an performance enhanced executable file and stores it in a ram disk however once this intial process it done you can stand to see upto 200% increase in performance and a severely reduced memory footprint for each of your php apps.</p>
]]></content:encoded>
			<wfw:commentRss>http://photogabble.co.uk/php/how-to-cut-down-wordpress-memory-usage.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Search Unleashed Drafts Bug.</title>
		<link>http://photogabble.co.uk/php/search-unleashed-drafts-bug.html</link>
		<comments>http://photogabble.co.uk/php/search-unleashed-drafts-bug.html#comments</comments>
		<pubDate>Sat, 18 Jul 2009 16:45:47 +0000</pubDate>
		<dc:creator>simon</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://photogabble.co.uk/?p=2118</guid>
		<description><![CDATA[I have recently installed a new search plugin for wordpress called Search Unleashed, after experimenting with its use for a clients project I realised a very basic however extremely anoying bug where the search results include all your drafts as well as public posts. I spent a few hours searching through the plugins code before [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently installed a new search plugin for wordpress called <a href="http://urbangiraffe.com/plugins/search-unleashed/">Search Unleashed</a>, after experimenting with its use for a clients project I realised a very basic however extremely anoying <a href="http://urbangiraffe.com/tracker/issues/show/661">bug </a>where the search results include all your drafts as well as public posts. I spent a few hours searching through the plugins code before giving up due to its complexity and being away from my desk meant I had no debugging tools at hand to help.</p>
<p>As a quick fix to the problem I have included the following if clause in my search.php template file:</p>
<pre>if ( $post--&gt;post_status == 'publish' ){ ... }</pre>
<p>Its not the best way to fix things, but it works for now and until I get back home next week its the best I can do. I hope this helps other people with similar problem until the plugin developer fixes things.</p>
]]></content:encoded>
			<wfw:commentRss>http://photogabble.co.uk/php/search-unleashed-drafts-bug.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress: get_post_ancestors()</title>
		<link>http://photogabble.co.uk/php/wordpress-get_post_ancestors.html</link>
		<comments>http://photogabble.co.uk/php/wordpress-get_post_ancestors.html#comments</comments>
		<pubDate>Fri, 17 Apr 2009 13:15:43 +0000</pubDate>
		<dc:creator>simon</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[flag]]></category>
		<category><![CDATA[selector]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://photogabble.co.uk/?p=1370</guid>
		<description><![CDATA[In adding a few slight modifications to the photogabble theme and because a design I&#8217;m working on for someone else required it; I managed to stumble upon a ridiculously simple solution to a over complected problem, how to find the post parent when the child post is more than one level deep. I had been [...]]]></description>
			<content:encoded><![CDATA[<p>In adding a few slight modifications to the photogabble theme and because a design I&#8217;m working on for someone else required it; I managed to stumble upon a ridiculously simple solution to a over complected problem, how to find the post parent when the child post is more than one level deep.</p>
<p>I had been using the following code to do this:</p>
<pre>if($post-&gt;post_parent=="11"{ ... }</pre>
<p>While this simple switch works if you are one layer deep for example Fish (ID 11) &gt; Tropical Fish (ID 12) it wont work if your more than two layers deep such as Fish (ID 11) &gt; Tropical Fish (ID 12) &gt; Amazon Fish (ID 13) because $post_post_parent for Amazon Fish becomes 12 not 11. In terms of programming this is all very logical, however the solution to finding out the original post_parent otherwise known as the grandparent or great grandparent is not very well documented and it was only luck that helped me stumble upon it. The very simple function get_post_ancestors() solves this problem by effectively returning an array with every post id related to the one in which it was called as the following example shows:</p>
<pre>$ancestors = get_post_ancestors();</pre>
<p>$ancestors now becomes an array which we can search through the php <a href="http://php.net/in_array">in_array</a> command by the following code:</p>
<pre>in_array(11,$ancestors);</pre>
<p>In this example if one of the $post_id&#8217;s of the current posts ancestors is 11 then the in_array function will return with true, otherwise it will return false. This then makes showing information on all sub pages (child pages) of Fish(ID 11) a simple matter of using the following code:</p>
<pre>$ancestors = get_post_ancestors($post);
if(in_array(11,$ancestors)){
	...
}</pre>
<p>I use this on my <a href="http://photogabble.co.ukprojects/">projects page&#8217;s</a> to provide a link back to the projects page from the sidebar of all its children, it could also be used to show a custom header for that section of your blog or certain links from a link category relevant to that section. The usefulness of this function is never ending and should be one of many you use when writing your own templates.</p>
]]></content:encoded>
			<wfw:commentRss>http://photogabble.co.uk/php/wordpress-get_post_ancestors.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Setup PHP with cURL</title>
		<link>http://photogabble.co.uk/php/setup-php-with-curl.html</link>
		<comments>http://photogabble.co.uk/php/setup-php-with-curl.html#comments</comments>
		<pubDate>Wed, 15 Apr 2009 19:32:41 +0000</pubDate>
		<dc:creator>simon</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[apt-get]]></category>
		<category><![CDATA[cURL]]></category>
		<category><![CDATA[php5]]></category>

		<guid isPermaLink="false">http://photogabble.co.uk/?p=1309</guid>
		<description><![CDATA[I recently upgraded my server from php4 to php5, I did the usual basic php5 install using apt-get and have had to add various libraries as and when I need them. Doing this is relatively simple on debian with the apt-get command. Simply enter the following into your terminal session: sudo apt-get install curl libcurl3 [...]]]></description>
			<content:encoded><![CDATA[<p>I recently upgraded my server from php4 to php5, I did the usual basic php5 install using apt-get and have had to add various libraries as and when I need them. Doing this is relatively simple on debian with the apt-get command. Simply enter the following into your terminal session:</p>
<pre>sudo apt-get install curl libcurl3 libcurl3-dev php5-curl</pre>
<p>If you dont have sudo installed then simply enter it without then enter the following to reboot your apache server for the changes to take effect.</p>
<pre>sudo /etc/init.d/apache2 restart</pre>
<p>Again if you dont have sudo installed then remove it from the line before you press return and cURL will be fully working &#8211; enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://photogabble.co.uk/php/setup-php-with-curl.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing a template for Cube Cart.</title>
		<link>http://photogabble.co.uk/design/writing-a-template-for-cube-cart.html</link>
		<comments>http://photogabble.co.uk/design/writing-a-template-for-cube-cart.html#comments</comments>
		<pubDate>Sat, 14 Jun 2008 17:14:59 +0000</pubDate>
		<dc:creator>simon</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[cubecart]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://photogabble.co.uk/?p=679</guid>
		<description><![CDATA[My most recent client project spec is to produce an online shop, while this initially didn&#8217;t appear to be an issue for me as I am quite able to create the design. I never once thought how difficult it would be to code the template for that design. It appears that while there are only [...]]]></description>
			<content:encoded><![CDATA[<p>My most recent client project spec is to produce an online shop, while this initially didn&#8217;t appear to be an issue for me as I am quite able to create the design. I never once thought how difficult it would be to code the template for that design. It appears that while there are only a hand-full of useful online shop software packages they each use a complex and rarely documented templating system. For this project I have chosen cube cart as it includes many of the mechanisms that my client requires and out of those I have tested it appears to be the most stable and &#8220;easy&#8221; to design for. I suppose to the first time on looker, the template system utilized by WordPress would be a little confusing and while I find it easy to use, I have been working with WordPress for a considerable number of years. I only hope I can get to knowing how to use the Cube Cart template system as easily as I did with WordPress. Has anyone else developed for cube cart and do you know of any online documentation I may find of use as google has given me nothing but multiple template websites trying to sell me something.</p>
]]></content:encoded>
			<wfw:commentRss>http://photogabble.co.uk/design/writing-a-template-for-cube-cart.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3 Days in 1.340952 seconds.</title>
		<link>http://photogabble.co.uk/php/3-days-in-1340952-seconds.html</link>
		<comments>http://photogabble.co.uk/php/3-days-in-1340952-seconds.html#comments</comments>
		<pubDate>Sun, 29 Apr 2007 03:10:45 +0000</pubDate>
		<dc:creator>simon</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Website Update]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.photogabble.co.uk/new/2007/04/29/3-days-in-1340952-seconds/</guid>
		<description><![CDATA[When you sit down in front of the computer and work hard for three days on a project, you don&#8217;t tend to expect it to accumulate to just pressing a button and never using the proceeds of your work again. However that is exactly what happened to me the past three days while trying to [...]]]></description>
			<content:encoded><![CDATA[<p>When you sit down in front of the computer and work hard for three days on a project, you don&#8217;t tend to expect it to accumulate to just pressing a button and never using the proceeds of your work again. However that is exactly what happened to me the past three days while trying to clean up this blogs database. There was too much stuff in there that I had picked up from &#8220;dirty&#8221; plugins and somehow that extra baggage was causing the administration area of my WordPress install to break, it had to have been the database as wiped the previous installs files and then re-installed WordPress using the same old database.</p>
<p>I wrote a custom script in php to copy select bits of my old WordPress database and after filtering out and changing select bits inserting them into the new WordPress install. It took three attempts due to me forgetting certain bits and general bugs however after a little bit of playing I managed to get the whole thing to work, over a thousand MySQL queries in a second later and everything is done. I now have a nice clean install with all my old posts and comments, new clean plugins and a beautiful hand made and coded design. What more could a blogger ask for?</p>
]]></content:encoded>
			<wfw:commentRss>http://photogabble.co.uk/php/3-days-in-1340952-seconds.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>time_since</title>
		<link>http://photogabble.co.uk/php/time_since.html</link>
		<comments>http://photogabble.co.uk/php/time_since.html#comments</comments>
		<pubDate>Fri, 20 Apr 2007 01:14:28 +0000</pubDate>
		<dc:creator>simon</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[time_since]]></category>

		<guid isPermaLink="false">http://www.photogabble.co.uk/2007/04/20/time_since/</guid>
		<description><![CDATA[I found it incredibly difficult to find any form of time_since function in php so to save anyone else the trouble to hunting through hundreds of useless websites here is the function you may want to use, written by Natalie Downe (you don&#8217;t want to know how long it took to hunt it down). It [...]]]></description>
			<content:encoded><![CDATA[<p>I found it incredibly difficult to find any form of time_since function in php so to save anyone else the trouble to hunting through hundreds of useless websites here is the function you may want to use, written by <a href="http://notes.natbat.net/2007/01/27/timesince/">Natalie Downe</a> (you don&#8217;t want to know how long it took to hunt it down). It takes the input in the form of the unix time stamp.</p>
<pre><code>function time_since($original) {

// array of time period chunks

$chunks = array(

array(60 * 60 * 24 * 365 , 'year' ),

array(60 * 60 * 24 * 30 , 'month' ),

array(60 * 60 * 24 * 7, 'week' ),

array(60 * 60 * 24 , 'day' ),

array(60 * 60 , 'hour' ),

array(60 , 'minute' ),

);</code><code>$today = time(); /* Current unix time */

$since = $today - $original;</code>

<code>// $j saves performing the count function each time around the loop

for ($i = 0, $j = count($chunks); $i &lt; $j; $i++) {</code>

<code>    $seconds = $chunks[$i][0];

$name = $chunks[$i][1];</code>

<code>    // finding the biggest chunk (if the chunk fits, break)

if (($count = floor($since / $seconds)) != 0) {

// DEBUG print "&lt;!-- It's $name --&gt;n";

break;

}

}</code>

<code>$print = ($count == 1) ? '1 '.$name : "$count {$name}s";</code>

<code>if ($i + 1 &lt; $j) {

// now getting the second item

$seconds2 = $chunks[$i + 1][0];

$name2 = $chunks[$i + 1][1];</code>

<code>    // add second item if it's greater than 0

if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0) {

$print .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$name2}s";

}

}

return $print;

}</code></pre>
<p>I also found a second more compact version from <a href="http://www.byteinsider.com/article/short-and-accurate-time_since-php-function">byteinsider</a> their version (below) takes the input in the form of the MySQL  timestamp format (Y-m-d H:i:s) both functions output the same type of thing tho, so its up to you which you use.<br />
<code> </code></p>
<pre>function time_since($mysql_timestamp)

{

$names =  array('year','month','day','hour','minute','second');$r = time()-strtotime($mysql_timestamp) - date('Z');

$posted = array(date('Y',$r)-1970,date('n',$r)-1,date('d',$r)-1,

 date('G',$r)-0,date('i',$r)-0,date('s',$r)-0);

for($n = 0; $n &lt; 5 &amp;&amp; $posted[$n] == 0; $n++);

$output = $posted[$n].' '.$names[$n];

if($posted[$n] != 1) $output .='s';

if($n &lt; 5 &amp;&amp; $posted[$n+1] != 0)

{

 $output .= ' '.$posted[$n+1].' '.$names[$n+1];

 if($posted[$n+1] != 1) $output .='s';

}

return $output.' ago';

}</pre>
]]></content:encoded>
			<wfw:commentRss>http://photogabble.co.uk/php/time_since.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Function: Pi</title>
		<link>http://photogabble.co.uk/php/php-function-pi.html</link>
		<comments>http://photogabble.co.uk/php/php-function-pi.html#comments</comments>
		<pubDate>Fri, 11 Aug 2006 08:06:58 +0000</pubDate>
		<dc:creator>simon</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[calculation]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[pi]]></category>

		<guid isPermaLink="false">http://www.photogabble.co.uk/2006/08/11/php-function-pi/</guid>
		<description><![CDATA[Just randomly came up with this after reading about how pi was first discovered and calculated. Im thinking of writing code that calculates pi to many decimals but figuring this out was hard enough lol. &#60;?php Function mypi (){ return (16*(atan(1/5)) - (4*atan(1/239))); } ?&#62; Can be proved true when tested against php&#8217;s own Pi [...]]]></description>
			<content:encoded><![CDATA[<p>Just randomly came up with this after reading about how pi was first discovered and calculated. Im thinking of writing code that calculates pi to many decimals but figuring this out was hard enough lol.</p>
<pre><code>
&lt;?php

Function mypi (){

return (16*(atan(1/5)) - (4*atan(1/239)));

}

?&gt;
</code></pre>
<p>Can be proved true when tested against php&#8217;s own Pi fucntion.</p>
]]></content:encoded>
			<wfw:commentRss>http://photogabble.co.uk/php/php-function-pi.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some PHP tutorials</title>
		<link>http://photogabble.co.uk/php/some-php-tutorials.html</link>
		<comments>http://photogabble.co.uk/php/some-php-tutorials.html#comments</comments>
		<pubDate>Wed, 09 Aug 2006 16:22:38 +0000</pubDate>
		<dc:creator>simon</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.photogabble.co.uk/2006/08/09/some-php-tutorials/</guid>
		<description><![CDATA[Not so much tutorial than some random code I just wrote to help me with somthing else&#8230; &#60;?php error_reporting(E_ALL ^ E_NOTICE); /* set some vars */ $n = 0; $max = $_GET['max']; if (isset($_GET['current'])){ $min = $_GET['current']; }else{ $min = 0; } if (!isset($max)){ $max = 10; } /* lets get some data to work [...]]]></description>
			<content:encoded><![CDATA[<p>Not so much tutorial than some random code I just wrote to help me with somthing else&#8230;</p>
<pre><code>
&lt;?php
error_reporting(E_ALL ^ E_NOTICE);

/*
set some vars
*/

$n = 0;
$max = $_GET['max'];

if (isset($_GET['current'])){

$min = $_GET['current'];

}else{

$min = 0;

}

if (!isset($max)){

$max = 10;

}

/*
lets get some data to work with.
fills an array with 1000 items.
*/

$entries = array();

for ($i = 1; $i &lt;= 1000; $i++) {
$entries[$i] = $i;
}

/*
print the current results
*/

foreach($entries as $entry){

if ($n &lt;= ($max-1)){

if (!($n &lt; $min)){

echo $entry;

}

$n++;
}

}

/*
if we are not on first page of results
show a back button
*/

if ($n &gt; 10){
echo "&lt;br/&gt;";
$min = $n-20;
$bmax = $max - 10;
echo '&lt;a href="?current=' . $min . '&amp;max=' . $bmax  . '"&gt;Previous&lt;/a&gt;';
}
/*
print link to get next ten entries
*/

echo "&lt;br/&gt;";
$max = $max + 10;
echo '&lt;a href="?current=' . $n . '&amp;max=' . $max  . '"&gt;Next&lt;/a&gt;';

?&gt;
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://photogabble.co.uk/php/some-php-tutorials.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

