<?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>Papermashup.com &#187; MySQL</title>
	<atom:link href="http://papermashup.com/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://papermashup.com</link>
	<description>Ashley Ford :: CSS &#124; PHP &#124; JavaScript</description>
	<lastBuildDate>Wed, 07 Jul 2010 09:39:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>easypoll a side project</title>
		<link>http://papermashup.com/easypoll-a-side-project/</link>
		<comments>http://papermashup.com/easypoll-a-side-project/#comments</comments>
		<pubDate>Wed, 26 May 2010 16:45:51 +0000</pubDate>
		<dc:creator>Ashley</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Social Media]]></category>
		<category><![CDATA[Social Networks]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://papermashup.com/?p=1881</guid>
		<description><![CDATA[I was sat in the sun at the weekend and sporadically decided to do a little project like wedeliver you can read about the adventure I had building the 24hr project here.  This project on the other hand probably took about 24hrs to complete but I built it over a few days. It&#8217;s basically a site where you can create a simple 2 answer poll, you then take the link to the poll and share it on your networks allowing other users to participate ...]]></description>
			<content:encoded><![CDATA[<p>I was sat in the sun at the weekend and sporadically decided to do a little project like <a href="http://wedeliver.papermashup.com">wedeliver</a> you can read about the adventure I had building the 24hr project <a href="http://papermashup.com/we-deliver-a-24hr-project/">here</a>.  This project on the other hand probably took about 24hrs to complete but I built it over a few days. It&#8217;s basically a site where you can create a simple 2 answer poll, you then take the link to the poll and share it on your networks allowing other users to participate <a href="http://easypoll.papermashup.com">check it out here</a>. I wanted to make the whole experience as simple as possible with a basic interface so users can quickly create polls to share with friends. Naturally there are parts of the site i will improve in time small pieces of functionality. Each time a user creates a new poll it sends it to a custom twitter page here @easypoll which shows all the latest polls created.</p>
<p>Each poll has its own page, for example here&#8217;s a poll i created: <a href="http://easypoll.papermashup.com/poll/1">Visit Poll</a> the bar graph is generated using basic CSS and PHP to determine the percentages for the number of votes. <a href="http://papermashup.com/using-php-and-css-to-make-a-simple-graph/">Here&#8217;s a tutorial</a> I wrote a while back on how to implement a similar graph</p>
<h3>The Design</h3>
<p>Much like <a href="http://wedeliver.papermashup.com">wedeliver</a> I wanted to create an appealing interface that&#8217;s easy on the eye, simple to navigate as well as containing all the functionality needed.</p>
<p><img class="alignnone size-full wp-image-1886" title="easy1" src="http://papermashup.com/wp-content/uploads/2010/05/easy1.jpg" alt="" width="583" height="300" /></p>
<p><img class="alignnone size-full wp-image-1890" title="easy4" src="http://papermashup.com/wp-content/uploads/2010/05/easy4.jpg" alt="" width="583" height="300" /></p>
<p><img class="alignnone size-full wp-image-1888" title="easy2" src="http://papermashup.com/wp-content/uploads/2010/05/easy2.jpg" alt="" width="583" height="300" /></p>
<h3>Visit the site</h3>
<p>You can <a href="http://easypoll.papermashup.com">visit the site here</a> and create a poll yourself. As I said in my post about <a href="http://wedeliver.papermashup.com">wedeliver</a> as a designer and developer it&#8217;s really important to do personal projects as well as freelance work you learn so much more building small applications in your own time. </p>
]]></content:encoded>
			<wfw:commentRss>http://papermashup.com/easypoll-a-side-project/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>20 Complete scripts to download</title>
		<link>http://papermashup.com/20-complete-scripts-to-download/</link>
		<comments>http://papermashup.com/20-complete-scripts-to-download/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 22:01:20 +0000</pubDate>
		<dc:creator>Ashley</dc:creator>
				<category><![CDATA[API's]]></category>
		<category><![CDATA[Analytics]]></category>
		<category><![CDATA[Blogging]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Downloads]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Gallery]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Learn]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Social Networks]]></category>
		<category><![CDATA[Trends]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Web Tools]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Javascript Vimeo Tutorials API Downloads]]></category>

		<guid isPermaLink="false">http://papermashup.com/?p=1812</guid>
		<description><![CDATA[I&#8217;ve put together a nice little collection of scripts over the past year or so, and have decided as it&#8217;s approaching summer in the UK (sorry winter in Australia!) to do a download bundle of 20 assorted scripts where you can get the lot in one click for free! Although donations are also much appreciated. Check out the list below for all the details of the package. This collection is based on a variety of different techniques, from CSS, PHP jQuery to MySQL.

What&#8217;s in the ...]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve put together a nice little collection of scripts over the past year or so, and have decided as it&#8217;s approaching summer in the UK (sorry winter in Australia!) to do a download bundle of 20 assorted scripts where you can get the lot in one click for free! Although <a class="thickbox" title="Download And Donate" onclick="return false;" href="http://papermashup.com/wp-content/themes/arthemia/donate.php?download=http://papermashup.com/demos/bundle/bundle.zip&amp;keepThis=true&amp;TB_iframe=true&amp;height=220&amp;width=620">donations</a> are also much appreciated. Check out the list below for all the details of the package. This collection is based on a variety of different techniques, from CSS, PHP jQuery to MySQL.</p>
<p><img class="alignnone size-full wp-image-1834" title="boxes" src="http://papermashup.com/wp-content/uploads/2010/04/boxes.png" alt="" width="583" height="180" /></p>
<h3>What&#8217;s in the bundle?</h3>
<ol>
<li>
<h4>jQuery Drag &amp; Drop</h4>
<p>Using jQuery PHP and MySQL a complete drag and drop script that updates the database. <a href="http://papermashup.com/demos/jquery-drag-drop/">demo</a></li>
<li>
<h4>jQuery Delete</h4>
<p>Delete items using PHP jQuery using an AJAX request <a href="http://papermashup.com/demos/jquery-delete/">demo</a></li>
<li>
<h4>PHP jQuery and MySQL Autosuggest</h4>
<p>A powerful autosuggest script that searches a MySQL database to return you result <a href="http://papermashup.com/demos/autosuggest/">demo</a></li>
<li>
<h4>jQuery &amp; PHP username checker</h4>
<p>Checks the database to see if a chosen username exists in the database and returns true or false <a href="http://papermashup.com/demos/check-username/">demo</a></li>
<li>
<h4>CSS3 Buttons</h4>
<p>Styling elegant buttons using CSS3 <a href="http://papermashup.com/demos/css-buttons/">demo</a></li>
<li>
<h4>Feedburner Stats</h4>
<p>Using PHP and CURL to get your feedburner subscriber count <a href="http://papermashup.com/demos/feedburner-stats/">demo</a></li>
<li>
<h4>jQuery &amp; PHP username checker</h4>
<p>Checks the database to see if a chosen username exists in the database and returns true or false <a href="http://papermashup.com/demos/check-username/">demo</a></li>
<li>
<h4>jQuery image Zoom</h4>
<p>create a simple gallery with a hover image effect <a href="http://papermashup.com/demos/image-jquery/">demo</a></li>
<li>
<h4>jQuery PHP &amp; MySQL inline editing</h4>
<p>Edit page content directly in the browser inline using jQuery AJAX requests <a href="http://papermashup.com/demos/inline-editing/">demo</a></li>
<li>
<h4>jQuery Gallery</h4>
<p>Animated jQuery gallery with title and description <a href="http://papermashup.com/demos/jquery-gallery/index-title.html">demo</a></li>
<li>
<h4>Highlighting form inputs</h4>
<p>Highlight any input field using JavaScript <a href="http://papermashup.com/demos/jquery-highlighting-form-inputs/">demo</a></li>
<li>
<h4>jQuery JSON &amp; PHP</h4>
<p>Create a simple product gallery using JSONP PHP and MySQL <a href="http://papermashup.com/demos/jquery-json-php/">demo</a></li>
<li>
<h4>jQuery Tabs</h4>
<p>Simple tabs rendered using jQuery <a href="http://papermashup.com/demos/jquery-tabs/">demo</a></li>
<li>
<h4>jQuery XML</h4>
<p>build a product gallery parsing XML using jQuery <a href="http://papermashup.com/demos/jquery-xml/">demo</a></li>
<li>
<h4>jTruncate</h4>
<p>Using the jTruncate plugin to truncate text with a &#8216;more&#8217; link <a href="http://papermashup.com/demos/jtruncate/">demo</a></li>
<li>
<h4>PHP Page scrape</h4>
<p>Scrape page contents using PHP and CURL <a href="http://papermashup.com/demos/page-scrape/">demo</a></li>
<li>
<h4>AJAX Check</h4>
<p>Check to see if a normal GET or POST request was made or if an AJAX request was made <a href="http://papermashup.com/demos/ajax-check/">demo</a></li>
<li>
<h4>PHP Pagination</h4>
<p>A useful and raw PHP pagination script that could be adapted in to a class <a href="http://papermashup.com/demos/php-pagination/">demo</a></li>
<li>
<h4>jQuery Sliding Menu</h4>
<p>jQuery drop down slide in / out menu inspired by 9rules.com <a href="http://papermashup.com/demos/jquery-menu/">demo</a></li>
<li>
<h4>jQuery Tooltips</h4>
<p>An experimentation into building jQuery tooltips with AJAX requests, images etc <a href="http://papermashup.com/demos/tooltip/">demo</a></li>
</ol>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input name="cmd" type="hidden" value="_s-xclick" />
<input name="hosted_button_id" type="hidden" value="PHJ3K79G49EHN" />
<input alt="PayPal - The safer, easier way to pay online." name="submit" src="http://papermashup.com/wp-content/uploads/2010/04/donate.png" type="image" /> <img style="border: 0px;" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" border="0" alt="" width="1" height="1" /><br />
</form>
<p><a class="thickbox" title="Download And Donate" onclick="return false;" href="http://papermashup.com/wp-content/themes/arthemia/donate.php?download=http://papermashup.com/demos/bundle/bundle.zip&amp;keepThis=true&amp;TB_iframe=true&amp;height=220&amp;width=620"><img class="alignnone size-full wp-image-24" title="download" src="http://papermashup.com/wp-content/uploads/2009/01/download.png" alt="" /></a> </p>
]]></content:encoded>
			<wfw:commentRss>http://papermashup.com/20-complete-scripts-to-download/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Get started with CodeIgniter</title>
		<link>http://papermashup.com/get-started-with-codeigniter/</link>
		<comments>http://papermashup.com/get-started-with-codeigniter/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 09:01:59 +0000</pubDate>
		<dc:creator>Ashley</dc:creator>
				<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[headline]]></category>
		<category><![CDATA[CodeIgniter]]></category>

		<guid isPermaLink="false">http://papermashup.com/?p=1564</guid>
		<description><![CDATA[I&#8217;ve never really got the hang of PHP frameworks and have tended to use my own custom built CMS but even with this I still find myself writing the same code over and over again. In the past I&#8217;ve dabbled with CakePHP and the Zend Framework and not really got very far, so a few days ago I downloaded CodeIgniter. Although I&#8217;m extremely new to this I was pretty blown away by the simplicity of setting things up and getting an actual webpage that processes ...]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve never really got the hang of PHP frameworks and have tended to use my own custom built CMS but even with this I still find myself writing the same code over and over again. In the past I&#8217;ve dabbled with CakePHP and the Zend Framework and not really got very far, so a few days ago I downloaded <a href="http://codeignitor.com">CodeIgniter</a>. Although I&#8217;m extremely new to this I was pretty blown away by the simplicity of setting things up and getting an actual webpage that processes something online.</p>
<h3>How It Works</h3>
<p>CodeIgniter uses the MVC or Model View Controller architectural pattern, if your not familiar with MVC it is a logical object orientated development approach. below we look at a simple example of how we use the MVC.</p>
<p><img class="alignnone size-full wp-image-1568" title="mvc" src="http://papermashup.com/wp-content/uploads/2010/01/mvc.png" alt="mvc" width="583" height="300" /></p>
<h3>Controllers</h3>
<p>A controller is simply a class file that is named in a way that can be associated with a URI. For example if i have a controller with the filename account.php the URI to reach that page would be something like http://your-domain.com/account/ so you no longer need to fiddle with the .htaccess file and mod_rewrite to enable SEO friendly URI&#8217;s. The controller is the top level file for each page that allows you to include database requests in the form of &#8216;Models&#8217; and templates as &#8216;Views&#8217;. below is an example of a controller, This code would be saved in the file blog.php, it&#8217;s important to understand the naming convensions because the name of the file is always the name of the class with the first letter capitalised. Within the Blog class we have an index() function which is always loaded when the page is excecuted. For example if we had another function lets say &#8216;categories&#8217; the code within that function would only be executed if we visited  http://your-domain.com/blog/categories/ this is also the way you can pass url parameters into functions but we&#8217;ll leave that for another day. We&#8217;re loading our &#8216;View&#8217; in at the bottom and passing the array $data into it. Within the view file which would be called blogview.php if we wanted to echo the heading we&#8217;d simply echo $heading the same with the title. With the to do list we would need to setup a for each loop to cycle through the results in that array.</p>
<pre class="brush: php;">

class Blog extends Controller {

	function index()
	{
		$data['todo_list'] = array('Clean House', 'Call Mom', 'Run Errands');
		$data['title'] = 'My Real Title';
		$data['heading'] = 'My Real Heading';

		$this-&gt;load-&gt;view('blogview', $data);
	}
}
</pre>
<h3>Models</h3>
<p>As yet we&#8217;re not using a model, this is because our controller isn&#8217;t doing anything complex. If we wanted to connect to a database and get a set of results we would use a model which could look like the below. This is all the code we need to pull 10 results from the database which would be returned to the controller in an array. note that you would need to replace &#8216;tableName&#8217; with your own database table name.</p>
<pre class="brush: php;">
class Blogmodel extends Model {

    function Blogmodel()
    {
        // Call the Model constructor
        parent::Model();
    }

    function get_last_ten_entries()
    {
        $query = $this-&gt;db-&gt;get('tableName', 10);
        return $query-&gt;result();
    }

}
</pre>
<p>To include the model firstly you need to navigate to system/application/config/database.php and add your database connection details. then below you&#8217;ll see that i&#8217;ve modified the controller that we used earlier so it now connects to the database and gets our data. This will then be sent through to the &#8216;view&#8217;.</p>
<pre class="brush: php;">

class Blog extends Controller {

	function index()
	{

		$data['title'] = 'My Blog Site';
		$data['heading'] = '10 of my blogs';

                 // connect to DB and get data
                $this-&gt;load-&gt;database();
                $this-&gt;load-&gt;model('blogmodel');
		$data['query'] = $this-&gt;blogmodel-&gt;get_last_ten_entries();

		$this-&gt;load-&gt;view('blogview', $data);
	}
}
</pre>
<h3>Views</h3>
<p>Simply put a &#8216;View&#8217; is our template, it&#8217;s where our data gets rendered and is made pretty, you can have as many views as you like and pass whatever data you like into them it&#8217;s probably a good idea to have a header, main content area and footer, but for the purposes of this demo i&#8217;ve used one view where all the data is rendered.</p>
<pre class="brush: php;">

&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;
&lt;title&gt;&lt;?php echo $title;?&gt;&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;h1&gt;&lt;?php echo $heading;?&gt;&lt;/h1&gt;

&lt;?php foreach($query as $item):?&gt;

&lt;h2&gt;&lt;?php echo $item-&gt;title;?&gt;&lt;/h2&gt;
&lt;?php echo $item-&gt;content;?&gt;

&lt;?php endforeach;?&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>For more information on <a name="codeigniter link"></a> where you can find the download and user guide <a href="http://codeignitor.com">Click Here</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://papermashup.com/get-started-with-codeigniter/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Build a JSON and PHP product gallery</title>
		<link>http://papermashup.com/json-and-php-product-gallery/</link>
		<comments>http://papermashup.com/json-and-php-product-gallery/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 14:44:58 +0000</pubDate>
		<dc:creator>Ashley</dc:creator>
				<category><![CDATA[API's]]></category>
		<category><![CDATA[Downloads]]></category>
		<category><![CDATA[Gallery]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Tools]]></category>
		<category><![CDATA[headline]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[APIs]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>

		<guid isPermaLink="false">http://papermashup.com/?p=1479</guid>
		<description><![CDATA[As the title describes we&#8217;re going to look at making cross domain ajax requests using JSONP I&#8217;m also going to show you how to get data from a MySQL database and encode it into a JSON string which can be parsed using JavaScript. JSON stands for JavaScript Object Notation and essentially its a method which allows us to execute cross domain ajax requests without too much fuss. This post really follows on from my article about scraping content from a page but also allows you ...]]></description>
			<content:encoded><![CDATA[<p>As the title describes we&#8217;re going to look at making cross domain ajax requests using JSONP I&#8217;m also going to show you how to get data from a MySQL database and encode it into a JSON string which can be parsed using JavaScript. JSON stands for JavaScript Object Notation and essentially its a method which allows us to execute cross domain ajax requests without too much fuss. This post really follows on from my article about <a href="http://papermashup.com/use-jquery-and-php-to-scrape-page-content/">scraping content from a page</a> but also allows you to send and receive GET variables through the JSON request.</p>
<h3>What we&#8217;re going to build</h3>
<p>To give this tutorial a valid example we&#8217;re going to display a selection of product in a gallery as seen in the image below, <a href="http://papermashup.com/demos/jquery-json-php/">click here to see the demo page</a>.</p>
<p><img title="product-gallery" src="http://papermashup.com/wp-content/uploads/2010/01/product-gallery.png" alt="product-gallery" width="582" height="300" /></p>
<h3>The PHP code</h3>
<p>First we&#8217;re going to run through getting data from our database using a PHP while loop to get a selection of rows limited to 6. In the code below you can see that we&#8217;re getting the data and generating an array. After this we simply pass the array variable $rows into the PHP function json_encode() which will format our PHP array for us.</p>
<pre class="brush: php;">
include('connect.php');
	$sql = &quot;SELECT title, image, description FROM json_demo LIMIT 6&quot;;
	$result = mysql_query($sql);
		while($row = mysql_fetch_array($result))
		{
			 $rows[] = array(
			&quot;title&quot; =&gt; $row['title'],
			&quot;image&quot; =&gt; $row['image'],
			&quot;description&quot; =&gt; $row['description']);
		}

$json = json_encode($rows);

$callback = $_GET['callback'];
echo $callback.'('. $json . ')';	
</pre>
<h3>What the JSON looks like</h3>
<p>Below is the structured output from our json.php file.</p>
<pre class="brush: jscript;">
[ { &quot;description&quot; : &quot;B&amp;O is a Danish company that designs and manufactures audio products, television sets, and telephones. It was founded in 1925 by Peter Bang and Svend Olufsen&quot;,
    &quot;image&quot; : &quot;1.jpg&quot;,
    &quot;title&quot; : &quot;B&amp;O 5.1&quot;
  },
  { &quot;description&quot; : &quot;B&amp;O is a Danish company that designs and manufactures audio products, television sets, and telephones. It was founded in 1925 by Peter Bang and Svend Olufsen&quot;,
    &quot;image&quot; : &quot;2.jpg&quot;,
    &quot;title&quot; : &quot;B&amp;O TV&quot;
  },
  { &quot;description&quot; : &quot;Market leader in the UK. Roberts produce a wide range of DAB digital radios. Roberts is a consumer electronics company producing DAB, analogue and wi-fi ...&quot;,
    &quot;image&quot; : &quot;3.jpg&quot;,
    &quot;title&quot; : &quot;Roberts Radio&quot;
  },
  { &quot;description&quot; : &quot;Toshiba is a diversified manufacturer and marketer of advanced electronic and electrical products, spanning information &amp; communications equipment and systems&quot;,
    &quot;image&quot; : &quot;4.jpg&quot;,
    &quot;title&quot; : &quot;Toshiba TV&quot;
  },
  { &quot;description&quot; : &quot;B&amp;O is a Danish company that designs and manufactures audio products, television sets, and telephones. It was founded in 1925 by Peter Bang and Svend Olufsen&quot;,
    &quot;image&quot; : &quot;5.jpg&quot;,
    &quot;title&quot; : &quot;B&amp;O Audio&quot;
  },
  { &quot;description&quot; : &quot;B&amp;O is a Danish company that designs and manufactures audio products, television sets, and telephones. It was founded in 1925 by Peter Bang and Svend Olufsen&quot;,
    &quot;image&quot; : &quot;6.jpg&quot;,
    &quot;title&quot; : &quot;B&amp;O Remote&quot;
  }
]
</pre>
<p>Now we have the JSON format built we just need some JavaScript to parse the file and output our data. generating an ajax request for JSON is pretty straight forward. because what we&#8217;re doing is designed to work cross domain you can put an absolute URI in the request. With JSONP we must add a callback parameter which is passed into the beginning of the JSON string.</p>
<p>Once we have the data we&#8217;re cycling through the results and appending a div with the results into the page.</p>
<pre class="brush: jscript;">
$(&quot;document&quot;).ready(function () {

    $.getJSON('http://papermashup.com/demos/jquery-json-php/json.php?callback=?', function (data) {
        $(&quot;#content&quot;).html('');
        $.each(data, function (i, item) {

            $(&quot;#content&quot;).append('&lt;div class=&quot;product&quot;&gt;&lt;img src=&quot;http://papermashup.com/demos/jquery-json-php/images/' + item.image + '&quot; width=&quot;135&quot; height=&quot;138&quot;/&gt;&lt;div class=&quot;title&quot;&gt;' + item.title + '&lt;/div&gt;&lt;div class=&quot;description&quot;&gt;' + item.description + '&lt;/div&gt;&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;&lt;/div&gt;');

        });

    });
    $(&quot;#content&quot;).fadeIn(2000);
});
</pre>
<p><a href="http://papermashup.com/demos/jquery-json-php/"><img title="demo" src="http://papermashup.com/wp-content/uploads/2009/01/demo.png" alt="demo" /></a><a href="http://papermashup.com/demos/jquery-json-php/jquery-json-php.zip"><img title="download" src="http://papermashup.com/wp-content/uploads/2009/01/download.png" alt="download" /></a> </p>
]]></content:encoded>
			<wfw:commentRss>http://papermashup.com/json-and-php-product-gallery/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Easy PHP Pagination</title>
		<link>http://papermashup.com/easy-php-pagination/</link>
		<comments>http://papermashup.com/easy-php-pagination/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 12:33:12 +0000</pubDate>
		<dc:creator>Ashley</dc:creator>
				<category><![CDATA[Downloads]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Tools]]></category>
		<category><![CDATA[headline]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://papermashup.com/?p=1440</guid>
		<description><![CDATA[I&#8217;ve had a few pagination scripts over the years but I thought i&#8217;d share the one that i&#8217;m currently using as it&#8217;s a useful script to have in your toolbox. As a developer you&#8217;ll soon find a need to paginate data when displaying contents from the database, and rather than use JavaScript which could require all the data to be loaded into the page on load, we can use PHP to ensure that we&#8217;re only requesting the data that we need from the database. For ...]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had a few pagination scripts over the years but I thought i&#8217;d share the one that i&#8217;m currently using as it&#8217;s a useful script to have in your toolbox. As a developer you&#8217;ll soon find a need to paginate data when displaying contents from the database, and rather than use JavaScript which could require all the data to be loaded into the page on load, we can use PHP to ensure that we&#8217;re only requesting the data that we need from the database. For those who have no clue what i&#8217;m talking about. Pagination is a way of splitting up data into manageable chunks to display to a user, if you&#8217;ve spent more than two minutes on the internet chances are you&#8217;ve come into contact with some form of pagination. as a simple example you can checkout my homepage, at the bottom you&#8217;ll see a list of page numbers allowing you to browse through pages of data, this script was originally written by the guys over at <a href="http://www.strangerstudios.com/sandbox/pagination/diggstyle.php">Stranger Studios</a> and allows you to split data up with it being paginated across however many pages dynamically.</p>
<h3>The Code</h3>
<p><img src="http://papermashup.com/wp-content/uploads/2009/12/pag.png" alt="pag" title="pag" width="581" height="105" /></p>
<p>To start with you&#8217;ll see that we have our database connection file which we&#8217;re including into the page. Next you&#8217;ll see we&#8217;re setting three variables. &#8216;$tableName&#8217;, this refers to the table in your database that you want to get the data from, in our case it&#8217;s &#8216;countries_list&#8217;, &#8216;$targetpage&#8217; refers to whatever you&#8217;ve saved the file as, in the case of the demo we&#8217;re saving the file as &#8216;index.php&#8217;. &#8216;$limit&#8217; is the number of rows per page that we want to display from the database in the case of the demo you&#8217;ll see that we&#8217;re displaying just 10 rows.</p>
<p>Here are the main bullet points of what this file does in the simplest form.</p>
<ul>
<li>Set the three variables at the top of the page declaring our database table, document filename, and number of results to display per page</li>
<li>Next we connect to the database and count the number of rows, so we know exactly how much data we&#8217;re dealing with</li>
<li>As the current page number is passed as a GET variable we check to see if a page number has been passed if there isn&#8217;t one then we set it to the first page</li>
<li>Then we have the query for the page content</li>
<li>Now we work out the next and previous page number as well as the last page number</li>
<li>Now we have a set of if statements, to determine which page the user is currently on relative to the total pages, so we can work out whether we need to display the first two page numbers with dots etc</li>
<li>Finally we echo &#8216;$paginate&#8217; which will display our page numbers</li>
<li>Then we have our while loop which you can modify to suit your contents</li>
</ul>
<pre class="brush: php;">
&amp;amp;lt;?php
	include('connect.php');	

	$tableName=&amp;amp;quot;countries_list&amp;amp;quot;;
	$targetpage = &amp;amp;quot;index.php&amp;amp;quot;;
	$limit = 10; 

	$query = &amp;amp;quot;SELECT COUNT(*) as num FROM $tableName&amp;amp;quot;;
	$total_pages = mysql_fetch_array(mysql_query($query));
	$total_pages = $total_pages[num];

	$stages = 3;
	$page = mysql_escape_string($_GET['page']);
	if($page){
		$start = ($page - 1) * $limit;
	}else{
		$start = 0;
		}	

    // Get page data
	$query1 = &amp;amp;quot;SELECT * FROM $tableName LIMIT $start, $limit&amp;amp;quot;;
	$result = mysql_query($query1);

	// Initial page num setup
	if ($page == 0){$page = 1;}
	$prev = $page - 1;
	$next = $page + 1;
	$lastpage = ceil($total_pages/$limit);
	$LastPagem1 = $lastpage - 1;					

	$paginate = '';
	if($lastpage &amp;amp;gt; 1)
	{	

		$paginate .= &amp;amp;quot;&amp;amp;lt;div class='paginate'&amp;amp;gt;&amp;amp;quot;;
		// Previous
		if ($page &amp;amp;gt; 1){
			$paginate.= &amp;amp;quot;&amp;amp;lt;a href='$targetpage?page=$prev'&amp;amp;gt;previous&amp;amp;lt;/a&amp;amp;gt;&amp;amp;quot;;
		}else{
			$paginate.= &amp;amp;quot;&amp;amp;lt;span class='disabled'&amp;amp;gt;previous&amp;amp;lt;/span&amp;amp;gt;&amp;amp;quot;;	}

		// Pages
		if ($lastpage &amp;amp;lt; 7 + ($stages * 2))	// Not enough pages to breaking it up
		{
			for ($counter = 1; $counter &amp;amp;lt;= $lastpage; $counter++)
			{
				if ($counter == $page){
					$paginate.= &amp;amp;quot;&amp;amp;lt;span class='current'&amp;amp;gt;$counter&amp;amp;lt;/span&amp;amp;gt;&amp;amp;quot;;
				}else{
					$paginate.= &amp;amp;quot;&amp;amp;lt;a href='$targetpage?page=$counter'&amp;amp;gt;$counter&amp;amp;lt;/a&amp;amp;gt;&amp;amp;quot;;}
			}
		}
		elseif($lastpage &amp;amp;gt; 5 + ($stages * 2))	// Enough pages to hide a few?
		{
			// Beginning only hide later pages
			if($page &amp;amp;lt; 1 + ($stages * 2))
			{
				for ($counter = 1; $counter &amp;amp;lt; 4 + ($stages * 2); $counter++)
				{
					if ($counter == $page){
						$paginate.= &amp;amp;quot;&amp;amp;lt;span class='current'&amp;amp;gt;$counter&amp;amp;lt;/span&amp;amp;gt;&amp;amp;quot;;
					}else{
						$paginate.= &amp;amp;quot;&amp;amp;lt;a href='$targetpage?page=$counter'&amp;amp;gt;$counter&amp;amp;lt;/a&amp;amp;gt;&amp;amp;quot;;}
				}
				$paginate.= &amp;amp;quot;...&amp;amp;quot;;
				$paginate.= &amp;amp;quot;&amp;amp;lt;a href='$targetpage?page=$LastPagem1'&amp;amp;gt;$LastPagem1&amp;amp;lt;/a&amp;amp;gt;&amp;amp;quot;;
				$paginate.= &amp;amp;quot;&amp;amp;lt;a href='$targetpage?page=$lastpage'&amp;amp;gt;$lastpage&amp;amp;lt;/a&amp;amp;gt;&amp;amp;quot;;
			}
			// Middle hide some front and some back
			elseif($lastpage - ($stages * 2) &amp;amp;gt; $page &amp;amp;amp;&amp;amp;amp; $page &amp;amp;gt; ($stages * 2))
			{
				$paginate.= &amp;amp;quot;&amp;amp;lt;a href='$targetpage?page=1'&amp;amp;gt;1&amp;amp;lt;/a&amp;amp;gt;&amp;amp;quot;;
				$paginate.= &amp;amp;quot;&amp;amp;lt;a href='$targetpage?page=2'&amp;amp;gt;2&amp;amp;lt;/a&amp;amp;gt;&amp;amp;quot;;
				$paginate.= &amp;amp;quot;...&amp;amp;quot;;
				for ($counter = $page - $stages; $counter &amp;amp;lt;= $page + $stages; $counter++)
				{
					if ($counter == $page){
						$paginate.= &amp;amp;quot;&amp;amp;lt;span class='current'&amp;amp;gt;$counter&amp;amp;lt;/span&amp;amp;gt;&amp;amp;quot;;
					}else{
						$paginate.= &amp;amp;quot;&amp;amp;lt;a href='$targetpage?page=$counter'&amp;amp;gt;$counter&amp;amp;lt;/a&amp;amp;gt;&amp;amp;quot;;}
				}
				$paginate.= &amp;amp;quot;...&amp;amp;quot;;
				$paginate.= &amp;amp;quot;&amp;amp;lt;a href='$targetpage?page=$LastPagem1'&amp;amp;gt;$LastPagem1&amp;amp;lt;/a&amp;amp;gt;&amp;amp;quot;;
				$paginate.= &amp;amp;quot;&amp;amp;lt;a href='$targetpage?page=$lastpage'&amp;amp;gt;$lastpage&amp;amp;lt;/a&amp;amp;gt;&amp;amp;quot;;
			}
			// End only hide early pages
			else
			{
				$paginate.= &amp;amp;quot;&amp;amp;lt;a href='$targetpage?page=1'&amp;amp;gt;1&amp;amp;lt;/a&amp;amp;gt;&amp;amp;quot;;
				$paginate.= &amp;amp;quot;&amp;amp;lt;a href='$targetpage?page=2'&amp;amp;gt;2&amp;amp;lt;/a&amp;amp;gt;&amp;amp;quot;;
				$paginate.= &amp;amp;quot;...&amp;amp;quot;;
				for ($counter = $lastpage - (2 + ($stages * 2)); $counter &amp;amp;lt;= $lastpage; $counter++)
				{
					if ($counter == $page){
						$paginate.= &amp;amp;quot;&amp;amp;lt;span class='current'&amp;amp;gt;$counter&amp;amp;lt;/span&amp;amp;gt;&amp;amp;quot;;
					}else{
						$paginate.= &amp;amp;quot;&amp;amp;lt;a href='$targetpage?page=$counter'&amp;amp;gt;$counter&amp;amp;lt;/a&amp;amp;gt;&amp;amp;quot;;}
				}
			}
		}

				// Next
		if ($page &amp;amp;lt; $counter - 1){
			$paginate.= &amp;amp;quot;&amp;amp;lt;a href='$targetpage?page=$next'&amp;amp;gt;next&amp;amp;lt;/a&amp;amp;gt;&amp;amp;quot;;
		}else{
			$paginate.= &amp;amp;quot;&amp;amp;lt;span class='disabled'&amp;amp;gt;next&amp;amp;lt;/span&amp;amp;gt;&amp;amp;quot;;
			}

		$paginate.= &amp;amp;quot;&amp;amp;lt;/div&amp;amp;gt;&amp;amp;quot;;		

}
 echo $total_pages.' Results';
 // pagination
 echo $paginate;
?&amp;amp;gt;

&amp;amp;lt;ul&amp;amp;gt;

&amp;amp;lt;?php 

		while($row = mysql_fetch_array($result))
		{

		echo '&amp;amp;lt;li&amp;amp;gt;'.$row['country'].'&amp;amp;lt;/li&amp;amp;gt;';

		}

	?&amp;amp;gt;
&amp;amp;lt;/ul&amp;amp;gt;
</pre>
<h3>A bit of style</h3>
<p>Here&#8217;s the css to style you pagination</p>
<pre class="brush: css;">
.paginate {
font-family:Arial, Helvetica, sans-serif;
	padding: 3px;
	margin: 3px;
}

.paginate a {
	padding:2px 5px 2px 5px;
	margin:2px;
	border:1px solid #999;
	text-decoration:none;
	color: #666;
}
.paginate a:hover, .paginate a:active {
	border: 1px solid #999;
	color: #000;
}
.paginate span.current {
    margin: 2px;
	padding: 2px 5px 2px 5px;
		border: 1px solid #999;

		font-weight: bold;
		background-color: #999;
		color: #FFF;
	}
	.paginate span.disabled {
		padding:2px 5px 2px 5px;
		margin:2px;
		border:1px solid #eee;
		color:#DDD;
	}

	li{
		padding:4px;
		margin-bottom:3px;
		background-color:#FCC;
		list-style:none;}

	ul{margin:6px;
	padding:0px;}
</pre>
<p><a href="http://papermashup.com/demos/php-pagination/" name="Demo Image - PHP Pagination"><img src="http://papermashup.com/wp-content/uploads/2009/01/demo.png" alt="demo" title="demo"/></a><a href="http://papermashup.com/demos/php-pagination/php-pagination.zip" name="Download Image - PHP Pagination"><img src="http://papermashup.com/wp-content/uploads/2009/01/download.png" alt="download" title="download"/></a></p>
]]></content:encoded>
			<wfw:commentRss>http://papermashup.com/easy-php-pagination/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>Win a copy of &#8216;Easy PHP Websites with the Zend Framework&#8217; Christmas giveaway</title>
		<link>http://papermashup.com/win-christmas-giveaway/</link>
		<comments>http://papermashup.com/win-christmas-giveaway/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 11:43:23 +0000</pubDate>
		<dc:creator>Ashley</dc:creator>
				<category><![CDATA[API's]]></category>
		<category><![CDATA[Blogging]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Competitions]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Downloads]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Web Tools]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[headline]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[APIs]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[comps]]></category>
		<category><![CDATA[win]]></category>

		<guid isPermaLink="false">http://papermashup.com/?p=1351</guid>
		<description><![CDATA[&#8220;Easy PHP Websites with the Zend Framework&#8221; shows you how to use the powerful Zend Framework to build websites with amazing speed and efficiency. Embracing a teaching strategy of learning by doing, showing you how to build website features you&#8217;ll actually want to use within your own websites. Among other topics you&#8217;ll learn how to manage data submitted through web forms, send e-mail through your website (both text and HTML), manage the user registration, login, and password recovery processes, and even create a simple social ...]]></description>
			<content:encoded><![CDATA[<p>&#8220;Easy PHP Websites with the Zend Framework&#8221; shows you how to use the powerful Zend Framework to build websites with amazing speed and efficiency. Embracing a teaching strategy of learning by doing, showing you how to build website features you&#8217;ll actually want to use within your own websites. Among other topics you&#8217;ll learn how to manage data submitted through web forms, send e-mail through your website (both text and HTML), manage the user registration, login, and password recovery processes, and even create a simple social network. With free books updates for the life of the project, and access to almost five hours of companion video, &#8220;Easy PHP Websites with the Zend Framework&#8221; is the ultimate guide to the Zend Framework!</p>
<p><img src="http://papermashup.com/wp-content/uploads/2009/12/win.jpg" alt="win" title="win" width="582" height="140" class="alignnone size-full wp-image-1377" /></p>
<h3>The Competition</h3>
<p>Papermashup has teamed up with <a href="http://easyphpwebsites.com/books/v/Easy-PHP-Websites-with-the-Zend-Framework">EasyPHPWebsites.com</a> to give away <strong>three free copies of the e-book</strong> (including access to the videos). <a href="http://easyphpwebsites.com/books/v/Easy-PHP-Websites-with-the-Zend-Framework">Find out more about the book here</a><br />
Competition closes on the 14th of December 2009 with the three winners being announced shortly after the closing date. There is no cash alternative and no purchase necessary.</p>
<h3>How To Enter</h3>
<blockquote><p>This competition is now closed!</p></blockquote>
<ol>
<li>To enter simply post the below on twitter and we&#8217;ll pick three people from random. Couldn&#8217;t be easier!</li>
<style>
#twi{
width:570px;
border:3px solid #ccc;
padding:5px;
font-size:21px;
color:#000;
font-family:arial;
margin-top:10px;
height:70px;
}</p>
</style>
<form action="http://twitter.com/home/" method="get" target="_blank">
<textarea id="twi" name="status">@ashleyford &#038; @wjgilmore are giving away free copies of Easy PHP Websites with the Zend Framework. RT to enter http://twi.la/ew8zt</textarea></p>
<input type="submit" id="posttotwitter" value="Post to twitter to enter"/>
</form>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://papermashup.com/win-christmas-giveaway/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using Memcache With PHP</title>
		<link>http://papermashup.com/using-memcache-with-php/</link>
		<comments>http://papermashup.com/using-memcache-with-php/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 21:18:14 +0000</pubDate>
		<dc:creator>Ashley</dc:creator>
				<category><![CDATA[API's]]></category>
		<category><![CDATA[Memcache]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Social Networks]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Tools]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[headline]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://papermashup.com/?p=1231</guid>
		<description><![CDATA[I want to just start this little post with that fact that I donâ€™t know all the ins and outs of using Memcache but I have enough knowledge to just about get it working. I have access to a Mediatemple Dedicated Virtual Extreme server and managed to install it on the server using SSH, with the help of this little guide from Mediatemple which runs you through the installation process step by step.
Who uses Memcache?
Well Memcache was developed by Danga Interactive to enhance the speed ...]]></description>
			<content:encoded><![CDATA[<p>I want to just start this little post with that fact that I donâ€™t know all the ins and outs of using Memcache but I have enough knowledge to just about get it working. I have access to a Mediatemple Dedicated Virtual Extreme server and managed to install it on the server using SSH, with the help of this little guide from Mediatemple which runs you through the installation process step by step.</p>
<h3>Who uses Memcache?</h3>
<p>Well Memcache was developed by Danga Interactive to enhance the speed of LiveJournal.com, Memcache dropped the database load to almost nothing, yielding faster page load times for users, better resource utilization, and faster access to the databases on a Memcache miss. Currently FaceBook are the biggest users of Memcache. Infact FaceBook are using it so aggressively that they are chartering new territory, and helping to develop the open source project.</p>
<p><img src="http://papermashup.com/wp-content/uploads/2009/11/fb.png" alt="fb" title="fb" width="582" height="200" class="alignnone size-full wp-image-1221" /></p>
<h3>Whatâ€™s Memcached?</h3>
<p>So your reading this wondering what Iâ€™m talking about. Memcache is basically is a general-purpose distributed memory caching system, put that in English, it allows you to store any form of data in a â€˜temporary cacheâ€™ so wherever you go to do a database query, instead of just connecting to the database and getting the data we want we first check the memcache to see if our data is already stored. If the memcache returns nothing, then go to the database, get what youâ€™re looking for, then store it in the memcache for later:</p>
<p>There are five main functions that we use with Memcache and they are as follows:</p>
<ul>
<li>get() â€” gets the value for a specified key</li>
<li>set() â€” sets a given key with a given value</li>
<li>add() â€” adds to the cache, only if it doesnâ€™t already exist</li>
<li>replace() â€” sets in the cache only if the key already exists</li>
<li>flush() â€” removes all keys and cached data</li>
</ul>
<p><img src="http://papermashup.com/wp-content/uploads/2009/11/mem1.png" alt="mem1" title="mem1" width="582" height="87" class="alignnone size-full wp-image-1215" /></p>
<h3>The Code</h3>
<p>So once you have Memcache installed on your server you can connect to it and start caching stuff. Itâ€™s worth pointing out that you shouldnâ€™t go out and cache everything, itâ€™s really only useful when you have large amounts of data that are going to be requested regularly.</p>
<ol>
<li>So the first two lines setup the connection to Memcache.</li>
<li>The include is just my database connection script.</li>
<li>Next we set the key. When we store data using Memcache there are 3 parts to storing the data, those three parts are the key, the value, and the expiry time of the cached item. The key is used to reference the stored data. in this example you can see that the key is an MD5 hash of the database query.</li>
<li>we then check if the key exists in the cache. this will return true or false. if the data is found in the cache then we can access it.</li>
<li>If the data isn&#8217;t found in the cache we connect to the database to get it. we store the data in the cache by using the follow line:  $memcache->set($key, $row, TRUE, 20); $row refers to the array that we get from the database, notice the 20 at the end. This refers to the how long this item will expire in the cache. It is measured in seconds. </li>
</ol>
<pre class="brush: php;">

$memcache = new Memcache;
$memcache-&amp;gt;connect('127.0.0.1', 11211) or die (&amp;quot;Could not connect&amp;quot;);

include('includes/connect.php');

//set the key then check the cache
$key = md5(&amp;quot;SELECT * FROM memcached_test where name='ashley'&amp;quot;);
$get_result = $memcache-&amp;gt;get($key);
if ($get_result) {
echo $get_result['name'];
echo $get_result['username'];
echo &amp;quot;Data Pulled From Cache&amp;quot;;
}
else {
 // Run the query and get the data from the database then cache it
 $query=&amp;quot;SELECT * FROM memcached_test where name='ashley';&amp;quot;;
 $result = mysql_query($query);
 $row = mysql_fetch_array($result);
 print_r($row);
 $memcache-&amp;gt;set($key, $row, TRUE, 20); // Store the result of the query for 20 seconds
 echo &amp;quot;Data Pulled from the Database&amp;quot;;
}
</pre>
<p>This is a very simple example of how to use memcache, but I hope it has been an insight into how caching works. </p>
]]></content:encoded>
			<wfw:commentRss>http://papermashup.com/using-memcache-with-php/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
