<?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>The Tutorial Blog &#187; tutorial</title>
	<atom:link href="http://www.thetutorialblog.com/tag/tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thetutorialblog.com</link>
	<description></description>
	<lastBuildDate>Tue, 08 Nov 2011 19:21:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<image>
<link>http://www.thetutorialblog.com</link>
<url>http://www.thetutorialblog.com/wp-content/plugins/maxblogpress-favicon/icons/favicon-28.ico</url>
<title>The Tutorial Blog</title>
</image>
		<item>
		<title>Creating a basic iPad application</title>
		<link>http://www.thetutorialblog.com/cocoa-objective-c/creating-a-basic-ipad-application/</link>
		<comments>http://www.thetutorialblog.com/cocoa-objective-c/creating-a-basic-ipad-application/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 18:47:44 +0000</pubDate>
		<dc:creator>Wez Pyke</dc:creator>
				<category><![CDATA[Cocoa/Objective-C]]></category>
		<category><![CDATA[Text Tutorials]]></category>
		<category><![CDATA[basic tutorial]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[create]]></category>
		<category><![CDATA[create a basic iPad application]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[ipad]]></category>
		<category><![CDATA[ipad app]]></category>
		<category><![CDATA[objc]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[UIKit]]></category>

		<guid isPermaLink="false">http://www.thetutorialblog.com/?p=287</guid>
		<description><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	Because of the recent announcement of the iPad 2 more people are going to want to learn how to develop for the iPhone OS. I recently purchased an iPad 2 3G with o2, so far the broadband has been flawless. This tutorial will be a basic walk-through for beginners who want to start developing. The [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fcocoa-objective-c%2Fcreating-a-basic-ipad-application%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fcocoa-objective-c%2Fcreating-a-basic-ipad-application%2F&amp;source=wezpyke&amp;style=normal&amp;service=bit.ly" height="61" width="50" title="Creating a basic iPad application" alt=" Creating a basic iPad application" /><br />
			</a>
		</div>
<p><img class="alignleft size-full wp-image-292" title="ipad" src="http://www.thetutorialblog.com/wp-content/uploads/2010/02/ipad.jpg" alt="ipad Creating a basic iPad application" width="450" height="338" /><br />
Because of the recent announcement of the <a href="http://www.apple.com/ipad/">iPad 2</a> more people are going to want to learn how to develop for the <a href="http://en.wikipedia.org/wiki/IPhone_OS">iPhone OS</a>. I recently purchased an iPad 2 3G with <a href="http://www.o2.co.uk/">o2</a>, so far the broadband has been flawless.</p>
<p>This tutorial will be a basic walk-through for beginners who want to start developing.</p>
<p>The application that we will be creating will consist of two button and one label.<br />
<span id="more-287"></span></p>
<h2>Create a new project</h2>
<p>First of all open Xcode and click "Create a new Xcode project". Select View-based Application and then iPad as the product.<br />
<img class="alignleft size-full wp-image-288" title="screenshot1" src="http://www.thetutorialblog.com/wp-content/uploads/2010/02/screenshot1.jpg" alt="screenshot1 Creating a basic iPad application" width="650" height="499" /></p>
<p>Save the project as Tutorial.</p>
<h2>Outlets and Actions</h2>
<p>For things such as labels and textfields we use IBOutlets and for buttons we use IBActions. IB stands for Interface Builder and is what we will use to create our interface and link the connections.</p>
<p>To add our outlets and actions open up TutorialViewController.h.</p>
<p>Under @interface TutorialViewController : UIViewController { add:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">IBOutlet UILabel <span style="color: #339933;">*</span>currentNumber<span style="color: #339933;">;</span></pre></div></div>

<p>Then before @end add:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>IBAction<span style="color: #009900;">&#41;</span>incrementNumber<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>sender<span style="color: #339933;">;</span>
<span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>IBAction<span style="color: #009900;">&#41;</span>decrementNumber<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>sender<span style="color: #339933;">;</span></pre></div></div>

<p>Save TutorialViewController.h.</p>
<h2>Create the interface and make connections</h2>
<p>Open up TutorialViewController.xib. From the library drag one labels and two buttons.<br />
<img class="alignleft size-full wp-image-289" title="screenshot2" src="http://www.thetutorialblog.com/wp-content/uploads/2010/02/screenshot2.jpg" alt="screenshot2 Creating a basic iPad application" width="650" height="510" /></p>
<p>Control + click the File's Owner object and drag it to the label then select currentNumber; now go from the minus and plus button to the File's Owner object and select decrementNumber for the minus button and incrementNumber for the plus button.<br />
<img class="alignleft size-full wp-image-290" title="screenshot3" src="http://www.thetutorialblog.com/wp-content/uploads/2010/02/screenshot3.jpg" alt="screenshot3 Creating a basic iPad application" width="650" height="432" /></p>
<p>Save TutorialViewController.xib and close Interface Builder.</p>
<h2>The Code</h2>
<p>Open TutorialViewController.m. Below the implementation we need to create an integer called number and set the value to 0.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">int</span> number <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span></pre></div></div>

<p>We now need to create methods for when the increment and decrement buttons are pressed.<br />
When the increment button is pressed we will increment the number integer by 1 then set the value of currentNumber to number by using a formatted string.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>IBAction<span style="color: #009900;">&#41;</span>incrementNumber<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>sender <span style="color: #009900;">&#123;</span>
	number<span style="color: #339933;">++;</span>
	<span style="color: #009900;">&#91;</span>currentNumber setText<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>NSString stringWithFormat<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;%d&quot;</span><span style="color: #339933;">,</span> number<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>and for decrement its the same but we decrement the number integer by 1.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>IBAction<span style="color: #009900;">&#41;</span>decrementNumber<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>sender <span style="color: #009900;">&#123;</span>
	number<span style="color: #339933;">-;</span>
	<span style="color: #009900;">&#91;</span>currentNumber setText<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>NSString stringWithFormat<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;%d&quot;</span><span style="color: #339933;">,</span> number<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>Build and Run</h2>
<p>Press the Build and Run button (command + return) and your app will compile then open.<br />
<img class="alignleft size-full wp-image-291" title="screenshot4" src="http://www.thetutorialblog.com/wp-content/uploads/2010/02/screenshot4.jpg" alt="screenshot4 Creating a basic iPad application" width="650" height="503" /></p>
<h2>Download</h2>
<p><a href="http://bit.ly/9Kqaok">Download</a></p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thetutorialblog.com/cocoa-objective-c/creating-a-basic-ipad-application/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Deep Linking with jQuery</title>
		<link>http://www.thetutorialblog.com/jquery/deep-linking-with-jquery/</link>
		<comments>http://www.thetutorialblog.com/jquery/deep-linking-with-jquery/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 14:43:43 +0000</pubDate>
		<dc:creator>Wez Pyke</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[deep linking]]></category>
		<category><![CDATA[deep linking tutorial]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery help]]></category>
		<category><![CDATA[jquery tutorial]]></category>
		<category><![CDATA[the tutorial blog]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[wez pyke]]></category>

		<guid isPermaLink="false">http://www.thetutorialblog.com/?p=243</guid>
		<description><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	You can view a demo and download the resources for this tutorial at the bottom of the post. Web 2.0 websites have a lot of Ajax functionality, some times when you load a new element of a page you may want the user to be able to click the back or forward button so that [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fjquery%2Fdeep-linking-with-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fjquery%2Fdeep-linking-with-jquery%2F&amp;source=wezpyke&amp;style=normal&amp;service=bit.ly" height="61" width="50" title="Deep Linking with jQuery" alt=" Deep Linking with jQuery" /><br />
			</a>
		</div>
<p><img src="http://www.thetutorialblog.com/wp-content/uploads/2010/02/Screen-shot-2010-02-10-at-14.52.00.png" alt="jQuery" title="jQuery" width="263" height="79" class="alignleft size-full wp-image-251" /></p>
<p><em>You can view a demo and download the resources for this tutorial at the bottom of the post.</em></p>
<p>Web 2.0 websites have a lot of Ajax functionality, some times when you load a new element of a page you may want the user to be able to click the back or forward button so that they can see the previously loaded content. One method to add this function to a website is to use the <a href="http://www.asual.com/jquery/address/">jQuery Address</a> plugin with jQuery. </p>
<p><a href="http://www.asual.com/jquery/address/">jQuery Addres</a>s has 4 main <a href="http://www.asual.com/jquery/address/docs/">methods</a>; <strong>init</strong>, <strong>change</strong>, <strong>internalChange</strong>, <strong>externalChange</strong>. The <strong>init</strong> method is what is called when the plugin is initiated. The <strong>change</strong> method is called when the URL is changed, an element in the page is changed or either the forward or backward button is pressed. The change method has the combined functionality of <strong>internalChange</strong> and <strong>externalChange</strong>. The <strong>internalChange</strong> is only called when a hyperlink inside the page is clicked; <strong>externalChange</strong> is only called when the URL is changed or the backward or forward button is pressed. </p>
<p>To allow deep linking within your website the only two methods that are required is <strong>init</strong> and <strong>change</strong>, you can then use <strong>internalChange</strong> and <strong>externalChange</strong> wherever you may need them. <br />
<span id="more-243"></span></p>
<h2>Getting it to work</h2>
<p>The first thing that is required of course is that you download the file for <a href="http://www.asual.com/jquery/address/">jQuery Address</a>. When you have done this copy the <em>jquery.address-1.1.min.js</em> file into the same location as your index.html file. </p>
<p>Now we include jQuery and the jQuery Address plugin, put this inside the head tags in your html file:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&lt;script src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
google.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;jquery&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;1.4.1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
&lt;script src=&quot;jquery.address-1.1.min.js&quot;&gt;&lt;/script&gt;</pre></div></div>

<h2>The jQuery</h2>
<p>The next thing that we're going to do is create a function that will be called when a hyperlink is clicked so that we know what file to load and where to load it. We will call this function <strong>loadURL()</strong>, it will take one parameter named url.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> loadURL<span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    	console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;loadURL: &quot;</span> <span style="color: #339933;">+</span> url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#area&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>We have console.log so that when we open up Firebug in Firefox we know which page is being requested. This is useful for debugging if there are any faults with the requested page loading. </p>
<p>We now set the jQuery Address event handlers so we know when to deep link an element within the page.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">address</span>.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	        console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;init: &quot;</span> <span style="color: #339933;">+</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[rel=address:'</span> <span style="color: #339933;">+</span> event.<span style="color: #660066;">value</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">']'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">change</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#area&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[rel=address:'</span> <span style="color: #339933;">+</span> event.<span style="color: #660066;">value</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">']'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    	console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;change&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>What this code does is retrieves the href attribute from a hyperlink by matching the rel to a hyperlink. We also log when it should have changed so we can see this in Firebug.</p>
<p>The last bit of jQuery that we do will check when a link has been pressed and then call the <strong>loadURL()</strong> function that we created before.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	    	loadURL<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This is what the head of your file should look like:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&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;TheTutorialBlog.com : jQuery Deep Linking&lt;/title&gt;
	&lt;script src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
	<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
	google.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;jquery&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;1.4.1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
	&lt;script src=&quot;jquery.address-1.1.min.js&quot;&gt;&lt;/script&gt;
&nbsp;
&nbsp;
	<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
	<span style="color: #009966; font-style: italic;">/*&lt;![CDATA[*/</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;document&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	    <span style="color: #003366; font-weight: bold;">function</span> loadURL<span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    	console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;loadURL: &quot;</span> <span style="color: #339933;">+</span> url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#area&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	    <span style="color: #006600; font-style: italic;">// Event handlers</span>
	    $.<span style="color: #660066;">address</span>.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	        console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;init: &quot;</span> <span style="color: #339933;">+</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[rel=address:'</span> <span style="color: #339933;">+</span> event.<span style="color: #660066;">value</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">']'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">change</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#area&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[rel=address:'</span> <span style="color: #339933;">+</span> event.<span style="color: #660066;">value</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">']'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    	console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;change&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
&nbsp;
	    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	    	loadURL<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009966; font-style: italic;">/*]]&gt;*/</span>
	<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
&lt;/head&gt;</pre></div></div>

<h2>The HTML</h2>
<p>The HTML for this is really basic stuff, we will create two hyperlinks that will load two separate files. We will also create a div element named area, this is where the files will be loaded.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;body&gt;
&nbsp;
&nbsp;
	&lt;a href=&quot;test1.html&quot; rel=&quot;address:/test1&quot;&gt;Test 1&lt;/a&gt; &lt;br /&gt;
	&lt;a href=&quot;test2.html&quot; rel=&quot;address:/test2&quot;&gt;Test 2&lt;/a&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;
&nbsp;
	Load Area: &lt;br /&gt;
	&lt;div id=&quot;area&quot;&gt;&lt;/div&gt;
&nbsp;
&nbsp;
&lt;/body&gt;</pre></div></div>

<p>The name of the file that you want to load goes inside the <strong>href</strong> tag. You also need to include <em>address:/</em> inside <strong>rel</strong>. This is how jQuery Address knows what hyperlinks you want to deep link.</p>
<h2>Final words</h2>
<p>I hope this tutorial has been useful, please feel free to leave a comment or ReTweet this tutorial on Twitter.</p>
<h2>Demo and Download</h2>
<p><a href="http://bit.ly/aU5vcT">Demo</a><br />
<a href="http://bit.ly/c95Qwa">Download</a></p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thetutorialblog.com/jquery/deep-linking-with-jquery/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>jQuery Dropdown Suggestions</title>
		<link>http://www.thetutorialblog.com/jquery/jquery-dropdown-suggestions/</link>
		<comments>http://www.thetutorialblog.com/jquery/jquery-dropdown-suggestions/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 21:36:24 +0000</pubDate>
		<dc:creator>Wez Pyke</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[dropdown box]]></category>
		<category><![CDATA[dropdown list]]></category>
		<category><![CDATA[dropdown menu]]></category>
		<category><![CDATA[suggestions]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.thetutorialblog.com/?p=181</guid>
		<description><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	For this tutorial we are going to create a drop down box similar to the one on the Google homepage when you start typing. The Markup The first thing that we must do is create the markup HTML. We are also going to include a stylesheet called style.css, we will create the CSS further down [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fjquery%2Fjquery-dropdown-suggestions%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fjquery%2Fjquery-dropdown-suggestions%2F&amp;source=wezpyke&amp;style=normal&amp;service=bit.ly" height="61" width="50" title="jQuery Dropdown Suggestions" alt=" jQuery Dropdown Suggestions" /><br />
			</a>
		</div>
<p><img src="http://www.thetutorialblog.com/wp-content/uploads/2010/01/jquerydropdownsuggestions.jpg" alt="jquery dropdown suggestions" title="jquery dropdown suggestions" width="300" height="300" class="alignleft size-full wp-image-182" />For this tutorial we are going to create a drop down box similar to the one on the <a href="http://www.google.com">Google</a> homepage when you start typing.</p>
<h2>The Markup</h2>
<p>The first thing that we must do is create the markup HTML. We are also going to include a stylesheet called style.css, we will create the CSS further down the tutorial.<br />
<span id="more-181"></span><br />
We need to create an input field and a DIV element, the DIV element is where the suggestions will be displayed.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&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;TheTutorialBlog.com - jQuery Dropdown Suggestions&lt;/title&gt;
	&lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot; type=&quot;text/css&quot; /&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;input type=&quot;text&quot; name=&quot;suggestions&quot; class=&quot;suggestionsinput&quot; value=&quot;Search&quot; /&gt;
	&lt;div id=&quot;suggestions&quot;&gt;
		Suggestions for &lt;span class=&quot;searchterm&quot;&gt;&lt;/span&gt;...
	&lt;/div&gt;&lt;!--suggestions--&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<h2>The CSS</h2>
<p>Create a file called style.css in the same folder.</p>
<p>We are going to give the input field and suggestions DIV rounded corners of 5 pixels. We will also hide the suggestions DIV because it should only be visible when a user starts to type.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">	body <span style="color: #00AA00;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ccc</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #6666ff;">.suggestionsinput</span> <span style="color: #00AA00;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">36px</span><span style="color: #00AA00;">;</span>
		-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
		-webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#999</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#999</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #cc00cc;">#suggestions</span> <span style="color: #00AA00;">&#123;</span>
		-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
		-webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">460px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#999</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">fixed</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">visibility</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h2>The jQuery</h2>
<p>Load the jQuery library from Google. Place this code below the include of the CSS file in your HTML file.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">	&lt;script src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
	<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
	google.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;jquery&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;1.3.2&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Below this code we will write our jQuery.</p>
<p>Check that the document is loaded.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">	<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
	$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// Code goes here</span>
&nbsp;
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>When the page is loaded the input field will display "Search", when the user clicks on the input field we want it to be blank so that they can start searching without having to delete the word.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">	<span style="color: #006600; font-style: italic;">// clear text from input</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.suggestionsinput&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.suggestionsinput&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;Search&quot;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.suggestionsinput&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>When the input field has been cleared the user will begin typing, we need to check to see if the user has started typing and if they have then we need to display the suggestions box.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">	<span style="color: #006600; font-style: italic;">// check if key has been pressed</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.suggestionsinput&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">keyup</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.suggestionsinput&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #006600; font-style: italic;">// make suggestions visible</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#suggestions&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'visibility'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'visible'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#suggestions&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#suggestions&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.searchterm&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.suggestionsinput&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #006600; font-style: italic;">// $(&quot;#suggestions&quot;).load('http://URL.to.load');</span>
&nbsp;
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #006600; font-style: italic;">// hide suggestions</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#suggestions&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeOut</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#suggestions&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'visibility'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'hidden'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>In this tutorial we are only making the drop down box visible, to load an actual list of suggestions uncomment <i>$("#suggestions").load('http://URL.to.load');</i> then specify a URL where your script is that will load your suggestions and return it to the user.</p>
<h2>The HTML File</h2>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">	&lt;!DOCTYPE html&gt;
	&lt;html lang=&quot;en&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;TheTutorialBlog.com - jQuery Dropdown Suggestions&lt;/title&gt;
		&lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot; type=&quot;text/css&quot; /&gt;
		&lt;script src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
		<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
		google.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;jquery&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;1.3.2&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
&nbsp;
		<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
		$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">// clear text from input</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.suggestionsinput&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.suggestionsinput&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;Search&quot;</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.suggestionsinput&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">// check if key has been pressed</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.suggestionsinput&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">keyup</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.suggestionsinput&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #006600; font-style: italic;">// make suggestions visible</span>
					$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#suggestions&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'visibility'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'visible'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#suggestions&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#suggestions&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.searchterm&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.suggestionsinput&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #006600; font-style: italic;">// $(&quot;#suggestions&quot;).load('http://URL.to.load');</span>
&nbsp;
				<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #006600; font-style: italic;">// hide suggestions</span>
					$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#suggestions&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeOut</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
						$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#suggestions&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'visibility'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'hidden'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
	&lt;/head&gt;
	&lt;body&gt;
		&lt;input type=&quot;text&quot; name=&quot;suggestions&quot; class=&quot;suggestionsinput&quot; value=&quot;Search&quot; /&gt;
		&lt;div id=&quot;suggestions&quot;&gt;
			Suggestions for &lt;span class=&quot;searchterm&quot;&gt;&lt;/span&gt;...
		&lt;/div&gt;&lt;!--suggestions--&gt;
	&lt;/body&gt;
	&lt;/html&gt;</pre></div></div>

<h2>The CSS File: style.css</h2>
<p>body {<br />
	background-color: #ccc;<br />
}</p>
<p>.suggestionsinput {<br />
	font-size: 36px;<br />
	-moz-border-radius: 5px;<br />
	-webkit-border-radius: 5px;<br />
	border: 1px solid #999;<br />
	color: #999;<br />
}</p>
<p>#suggestions {<br />
	-moz-border-radius: 5px;<br />
	-webkit-border-radius: 5px;<br />
	width: 460px;<br />
	background-color: #999;<br />
	position: fixed;<br />
	padding: 5px;<br />
	visibility: hidden;<br />
}<br />
</h2>
<h2>Download/Demo</h2>
<p><a href="http://bit.ly/9GyfKV">Download</a><br />
<a href="http://bit.ly/daBYdP">Demo</a></p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thetutorialblog.com/jquery/jquery-dropdown-suggestions/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Twitter-like pagination using CakePHP and jQuery</title>
		<link>http://www.thetutorialblog.com/php/twitter-like-pagination-using-cakephp-and-jquery/</link>
		<comments>http://www.thetutorialblog.com/php/twitter-like-pagination-using-cakephp-and-jquery/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 00:26:26 +0000</pubDate>
		<dc:creator>Wez Pyke</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Text Tutorials]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[wez pyke]]></category>

		<guid isPermaLink="false">http://www.thetutorialblog.com/?p=179</guid>
		<description><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	I have already done this tutorial with CodeIgniter and jQuery it can be found here. I thought I would do this tutorial again but rewrite it for CakePHP because it is a popular PHP framework. Before we start doing any PHP code make sure to copy in the code below into your MySQL database. CREATE [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fphp%2Ftwitter-like-pagination-using-cakephp-and-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fphp%2Ftwitter-like-pagination-using-cakephp-and-jquery%2F&amp;source=wezpyke&amp;style=normal&amp;service=bit.ly" height="61" width="50" title="Twitter like pagination using CakePHP and jQuery" alt=" Twitter like pagination using CakePHP and jQuery" /><br />
			</a>
		</div>
<p><img src="http://www.thetutorialblog.com/wp-content/uploads/2009/12/twitter_pagination_icon.jpg" alt="twitter pagination icon Twitter like pagination using CakePHP and jQuery" title="twitter_pagination_icon" width="300" height="300" class="alignleft size-full wp-image-168" />I have already done this tutorial with CodeIgniter and jQuery it can be found <a href="http://www.thetutorialblog.com/php/twitter-like-pagination-using-codeigniter-and-jquery/">here</a>. I thought I would do this tutorial again but rewrite it for CakePHP because it is a popular PHP framework.</p>
<p>Before we start doing any PHP code make sure to copy in the code below into your MySQL database.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span>  <span style="color: #ff0000;">`tutorials`</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">`twitter_messages`</span> <span style="color: #66cc66;">&#40;</span>
<span style="color: #ff0000;">`id`</span> INT <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span> <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">`username`</span> VARCHAR<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">30</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">`message`</span> VARCHAR<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">140</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>
<span style="color: #66cc66;">&#41;</span> ENGINE <span style="color: #66cc66;">=</span> INNODB</pre></div></div>

<h2>Create the controller</h2>
<p>Under the folder named controller create a file and call it twitter_controller.php.</p>
<p>We create a class inside it called TwitterController and it will extend AppController. We then set the name of the controller to twitter and tell CakePHP which table we are using in our database.<br />
<span id="more-179"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> TwitterController <span style="color: #000000; font-weight: bold;">extends</span> AppController <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'twitter'</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$uses</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'twitter_messages'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;</span>pre<span style="color: #339933;">&gt;</span>
&nbsp;
In this controller we will have two methods index and get_messages<span style="color: #339933;">.</span> Our index method will have no parameters and get_messages will have one parameter so that we know what the offset of the <span style="color: #990000;">current</span> number of messages loaded<span style="color: #339933;">.</span>
&nbsp;
Inside our index method we will retrieve the number of messages in the table and also the first <span style="color: #cc66cc;">10</span> records<span style="color: #339933;">.</span>
&nbsp;
<span style="color: #339933;">&lt;</span>pre lang<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;php&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'num_messages'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">twitter_messages</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">num_messages</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'messages'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">twitter_messages</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_messages</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In our second method called get_messages we grab the 10 latest messages for when it is called via jQuery.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> get_messages<span style="color: #009900;">&#40;</span><span style="color: #000088;">$offset</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'latest_messages'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">twitter_messages</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_messages</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$offset</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>Model</h2>
<p>Under the models folder create a file and name it twitter_messages.php.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> Twitter_messages <span style="color: #000000; font-weight: bold;">extends</span> AppModel <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'twitter_messages'</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> get_messages<span style="color: #009900;">&#40;</span><span style="color: #000088;">$offset</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$messages</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'all'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'offset'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$offset</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'limit'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$messages</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> num_messages<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'count'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>These two methods in the model are called from the controller.</p>
<h2>View</h2>
<p>Create a folder called twitter inside the views folder. Then create a file called index.ctp and get_messages.ctp.</p>
<h3>index.ctp</h3>
<p>Inside the index file copy this css and jQuery code.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;style&gt;
#main_content {
	border: #999 1px solid;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	padding: 5px;
}
&nbsp;
#more_button {
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	color: #990000;
	text-align: center;
	padding: 5px;
	background-color: #fff;
	background-image: url(&quot;http://s.twimg.com/a/1261078355/images/more.gif&quot;);
	background-repeat: repeat-x;
	cursor: pointer;
	border: 1px solid #AAA;
}
&nbsp;
#more_button:hover {
	border:1px solid #bbb;
	text-decoration:none;
	background-position:left -78px;
}
&lt;/style&gt;
&lt;script src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
google.load(&quot;jquery&quot;, &quot;1.3.2&quot;);
&lt;/script&gt;
&nbsp;
&lt;script type=&quot;text/javascript&quot;&gt;
		$(document).ready(function(){
		var num_messages = &lt;?=$num_messages?&gt;;
		var loaded_messages = 0;
			$(&quot;#more_button&quot;).click(function(){
				loaded_messages += 10;
				$.get(&quot;twitter/get_messages/&quot; + loaded_messages, function(data){
					$(&quot;#main_content&quot;).append(data);
&nbsp;
				});
&nbsp;
				if(loaded_messages &gt;= num_messages - 10)
				{
					$(&quot;#more_button&quot;).hide();
					//alert('hide');
				}
			})
		})
	&lt;/script&gt;</pre></div></div>

<p>Below this copy in the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;div id=&quot;main_content&quot;&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$messages</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'twitter_messages'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' - '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'twitter_messages'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/div&gt;
&nbsp;
&lt;div id=&quot;more_button&quot;&gt;
	more
&lt;/div&gt;</pre></div></div>

<p>Here we are displaying the first 10 records in the database then when the more button is clicked an ajax request will retrieve 10 more.</p>
<h3>get_messages.ctp</h3>
<p>This file is the file that is called upon the ajax request. This will display the 10 latest retrieve records.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$latest_messages</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'twitter_messages'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' - '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'twitter_messages'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h2>Final words</h2>
<p>I hope this tutorial has been useful to you, please Retweet it if it was useful for you. You can also follow me <a href="http://twitter.com/wezpyke">@wezpyke</a></p>
<h2>Download</h2>
<p><a href="http://bit.ly/91Rptr">Download the resources for this tutorial</a></p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thetutorialblog.com/php/twitter-like-pagination-using-cakephp-and-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Twitter-like pagination using CodeIgniter and jQuery</title>
		<link>http://www.thetutorialblog.com/php/twitter-like-pagination-using-codeigniter-and-jquery/</link>
		<comments>http://www.thetutorialblog.com/php/twitter-like-pagination-using-codeigniter-and-jquery/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 16:30:57 +0000</pubDate>
		<dc:creator>Wez Pyke</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Text Tutorials]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[CI]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[twitter pagination]]></category>

		<guid isPermaLink="false">http://www.thetutorialblog.com/?p=167</guid>
		<description><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	If you use Twitter you'll notice that there is a more button at the bottom at the bottom of your timeline, when you click this more tweets appear. This is Twitters way of paginating a page. In this tutorial I'll show you how to create a pagination system using CodeIgniter and jQuery that is almost [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fphp%2Ftwitter-like-pagination-using-codeigniter-and-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fphp%2Ftwitter-like-pagination-using-codeigniter-and-jquery%2F&amp;source=wezpyke&amp;style=normal&amp;service=bit.ly" height="61" width="50" title="Twitter like pagination using CodeIgniter and jQuery" alt=" Twitter like pagination using CodeIgniter and jQuery" /><br />
			</a>
		</div>
<p><img src="http://www.thetutorialblog.com/wp-content/uploads/2009/12/twitter_pagination_icon.jpg" alt="twitter pagination icon Twitter like pagination using CodeIgniter and jQuery" title="twitter_pagination_icon" width="300" height="300" class="alignleft size-full wp-image-168" />If you use Twitter you'll notice that there is a more button at the bottom at the bottom of your timeline, when you click this more tweets appear. This is Twitters way of paginating a page. In this tutorial I'll show you how to create a pagination system using CodeIgniter and jQuery that is almost identical to Twitters.</p>
<p>First of all copy this SQL into your database to create a table that we will be using to grab rows from.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span>  <span style="color: #ff0000;">`tutorials`</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">`twitter_messages`</span> <span style="color: #66cc66;">&#40;</span>
<span style="color: #ff0000;">`id`</span> INT <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span> <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">`username`</span> VARCHAR<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">30</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">`message`</span> VARCHAR<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">140</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>
<span style="color: #66cc66;">&#41;</span> ENGINE <span style="color: #66cc66;">=</span> INNODB</pre></div></div>

<p><span id="more-167"></span></p>
<h2>Create the controller</h2>
<p>The class we create is going to be called twitterpagination:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> twitterpagination <span style="color: #000000; font-weight: bold;">extends</span> Controller <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>inside the controller class create a function called index()</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">model</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twitterpagination_model'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'num_messages'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">twitterpagination_model</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">num_messages</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'latest_messages'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">twitterpagination_model</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_messages</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twitterpagination/index'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>We load the url helper because we will be using base_url() in our view to link to our stylesheet. The model we will be creating is twitterpagination_model so we call this also. $data['num_messages'] returns the number of messages in the database and $data['lastest_messages'] loads the 10 newest rows from the database. Lastly we include a view that we will be creating and pass in $data.</p>
<p>Inside the controller I have created two more functions insert_rows() and get_messages(). The function insert_rows() will insert 50 examples rows for us to retrieve from the table.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> insert_rows<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">database</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
		<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'username'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'user'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'message'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'message '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">insert</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twitter_messages'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$i</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The last function we have in our controller is get_messages()</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> get_messages<span style="color: #009900;">&#40;</span><span style="color: #000088;">$offset</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">model</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twitterpagination_model'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'latest_messages'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">twitterpagination_model</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_messages</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$offset</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twitterpagination/get_messages'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This function will be called from the view using an ajax call. We have one parameter called $offset, we use this so we know where to pull the next set of rows from in the table. We simply include the twitterpagination_model, call the get_messages() function from the model and pass in the data to the view.</p>
<p>Here is all of the controller code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> twitterpagination <span style="color: #000000; font-weight: bold;">extends</span> Controller <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">model</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twitterpagination_model'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'num_messages'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">twitterpagination_model</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">num_messages</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'latest_messages'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">twitterpagination_model</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_messages</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twitterpagination/index'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> insert_rows<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">database</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
			<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'username'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'user'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'message'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'message '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">insert</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twitter_messages'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$i</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> get_messages<span style="color: #009900;">&#40;</span><span style="color: #000088;">$offset</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">model</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twitterpagination_model'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'latest_messages'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">twitterpagination_model</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_messages</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$offset</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twitterpagination/get_messages'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Save this file as twitterpagination.php inside the controllers folder.</p>
<h2>The Model</h2>
<p>For the model we create a file called twitterpagination_model.php inside the models folder. Then we create a class called twitterpagination_model which extends Model.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> twitterpagination_model <span style="color: #000000; font-weight: bold;">extends</span> Model <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Next we create the function that will pull the messages from the table.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> get_messages<span style="color: #009900;">&#40;</span><span style="color: #000088;">$offset</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">order_by</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'desc'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twitter_messages'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #000088;">$offset</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">result</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>We order the ID descending so that the newest rows are called first. Then we create a variable called $query and retrieve the 10 latest messages from twitter_messages.</p>
<p>Another function that we create in the model is num_messages(). This function returns the number of messages and will be call in the view. This is so we know how many messages are in the table and when to hide the "more" button in the view so the user cannot see it anymore.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> num_messages<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">count_all_results</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twitter_messages'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$query</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>That is all we need to do for the controller.</p>
<h2>The View</h2>
<p>First of all create a folder called twitterpagination inside the views folder, then create two files called index.php and get_messages.php.</p>
<h2>The code for index.php</h2>
<p>The most important thing about this file is not to forget to include the jQuery library or the code will not work at all.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&lt;script src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
google.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;jquery&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;1.3.2&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Just below the inclusion of the jQuery library we will write our javascript.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
	$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> num_messages <span style="color: #339933;">=</span> <span style="color: #339933;">&lt;?=</span>$num_messages<span style="color: #339933;">?&gt;;</span>
	<span style="color: #003366; font-weight: bold;">var</span> loaded_messages <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#more_button&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			loaded_messages <span style="color: #339933;">+=</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span>
			$.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;twitterpagination/get_messages/&quot;</span> <span style="color: #339933;">+</span> loaded_messages<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#main_content&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>loaded_messages <span style="color: #339933;">&gt;=</span> num_messages <span style="color: #339933;">-</span> <span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#more_button&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #006600; font-style: italic;">//alert('hide');</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>After we have checked the DOM is ready we create two variables called num_messages and loaded_messages. The variable num_messages is the total number of messages in the table and loaded_messages will increase by 10 every time 10 more rows are retrieved.</p>
<p>We then have a click event for our more button that will send a request to the get_messages view that we will create.</p>
<p>Then we check if the number of loaded messages is the same as the total number off messages so that we know to hide the more button as there are no more rows to retrieve.</p>
<p>The next thing to do is to include the stylesheet.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;link rel=&quot;stylesheet&quot; href=&quot;&lt;?=base_url();?&gt;stylesheet/main.css&quot; type=&quot;text/css&quot; /&gt;</pre></div></div>

<p>Inside the body we include this html:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;main_content&quot;&gt;
&lt;?php
foreach($latest_messages as $message)
{
	echo $message-&gt;username . ' - ' . $message-&gt;message . '&lt;br /&gt;';
}
?&gt;
&lt;/div&gt;
&lt;div id=&quot;more_button&quot;&gt;
more
&lt;/div&gt;</pre></div></div>

<p>The div with the id of main_content is where the messages will be loaded and the div with id of more_button is our button that will be clicked to retrieve more messages.</p>
<p>Here is the full html/javascript of the index.php page.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&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;Twitter Pagination&lt;/title&gt;
	&lt;script src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
	&lt;script type=&quot;text/javascript&quot;&gt;
	google.load(&quot;jquery&quot;, &quot;1.3.2&quot;);
	&lt;/script&gt;
	&lt;script type=&quot;text/javascript&quot;&gt;
		$(document).ready(function(){
		var num_messages = &lt;?=$num_messages?&gt;;
		var loaded_messages = 0;
			$(&quot;#more_button&quot;).click(function(){
				loaded_messages += 10;
				$.get(&quot;twitterpagination/get_messages/&quot; + loaded_messages, function(data){
					$(&quot;#main_content&quot;).append(data);
&nbsp;
				});
&nbsp;
				if(loaded_messages &gt;= num_messages - 10)
				{
					$(&quot;#more_button&quot;).hide();
					//alert('hide');
				}
			})
		})
	&lt;/script&gt;
	&lt;link rel=&quot;stylesheet&quot; href=&quot;&lt;?=base_url();?&gt;stylesheet/main.css&quot; type=&quot;text/css&quot; /&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;div id=&quot;main_content&quot;&gt;
	&lt;?php
	foreach($latest_messages as $message)
	{
		echo $message-&gt;username . ' - ' . $message-&gt;message . '&lt;br /&gt;';
	}
	?&gt;
	&lt;/div&gt;
	&lt;div id=&quot;more_button&quot;&gt;
	more
	&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>The second view that we create is get_messages.php. This is the page that is called when the more button is clicked.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$latest_messages</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$message</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">username</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' - '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$message</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">message</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h2>Stylesheet</h2>
<p>The very last thing we need to do is create a stylesheet for our page to make it look a little nicer.</p>
<p>Create a folder named stylesheet in the root of the CodeIgniter folder and create a file in it called main.css. The path should be {CI_root}/stylesheet/main.php.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#main_content</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#999</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span><span style="color: #00AA00;">;</span>
	-webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#more_button</span> <span style="color: #00AA00;">&#123;</span>
	-webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#990000</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;http://s.twimg.com/a/1261078355/images/more.gif&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-repeat</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">repeat-x</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#AAA</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#more_button</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#bbb</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span> <span style="color: #933;">-78px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h2>Conclusion</h2>
<p>Don't forget to configure your database.php file in the config folder and also inside autoload.php make sure you auto load the database library.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$autoload</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'libraries'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'database'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I hope this tutorial has been of use to you, please feel free to post your thoughts and modifications.</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thetutorialblog.com/php/twitter-like-pagination-using-codeigniter-and-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Adding security to CodeIgniter forms with a custom library class</title>
		<link>http://www.thetutorialblog.com/php/adding-security-to-codeigniter-forms-with-a-custom-library-class/</link>
		<comments>http://www.thetutorialblog.com/php/adding-security-to-codeigniter-forms-with-a-custom-library-class/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 14:03:48 +0000</pubDate>
		<dc:creator>Wez Pyke</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Text Tutorials]]></category>
		<category><![CDATA[CI]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[question]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.thetutorialblog.com/?p=159</guid>
		<description><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	The class that we are going to create within CI will simply add a math question that the user will have to enter correctly to continue. This is useful to stop bots from mass submitting information to your forms. The class we are going to write is only very short and simple, but it will [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fphp%2Fadding-security-to-codeigniter-forms-with-a-custom-library-class%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fphp%2Fadding-security-to-codeigniter-forms-with-a-custom-library-class%2F&amp;source=wezpyke&amp;style=normal&amp;service=bit.ly" height="61" width="50" title="Adding security to CodeIgniter forms with a custom library class" alt=" Adding security to CodeIgniter forms with a custom library class" /><br />
			</a>
		</div>
<p>The class that we are going to create within CI will simply add a math question that the user will have to enter correctly to continue. This is useful to stop bots from mass submitting information to your forms.</p>
<p>The class we are going to write is only very short and simple, but it will give you an idea of how to create classes for your own projects.</p>
<h2>Creating the new class</h2>
<p>First of all we need to create the file for the class, navigate to libraries then create a file called math_question.php.</p>
<p>All we are going to do within this class is generate two random numbers that will be added together.<br />
<span id="more-159"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> math_question <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> questionOne<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// generate a random number between 0 - 10</span>
		<span style="color: #000088;">$num</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$num</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> questionTwo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$num</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$num</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This is all we will be doing for the code within the class.</p>
<h2>Using the class within a form</h2>
<p>To use this class in our controller we load it like so:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'math_question'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>We will also be using form validation and sessions to check if the user has entered the correct answer.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'form_validation'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>We need to set questionOne and questionTwo in variables so we can assign them to a temporary flash session and because they will be passed into the view.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$questionOne</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">math_question</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">questionOne</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$questionTwo</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">math_question</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">questionTwo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_flashdata</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'questionOne'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$questionOne</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_flashdata</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'questionTwo'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$questionTwo</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'math_question'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;What is <span style="color: #006699; font-weight: bold;">{$questionOne}</span> + <span style="color: #006699; font-weight: bold;">{$questionTwo}</span>?&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>To check that the answer that is wrote in is correct we use the callback method in our form validation to call a function that we create that will check the users input against the flash data.</p>
<p>This is how we set our form validation:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_rules</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'math_question'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Math Question'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'callback_math_question'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Then we check if the validation has been executed:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">run</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'contact/form'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;success&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now we need to create our function that is called upon validation of the form:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> math_question<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$user_answer</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'math_question'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$questionOne</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">flashdata</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'questionOne'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$questionTwo</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">flashdata</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'questionTwo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$correct_answer</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$questionOne</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$questionTwo</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$user_answer</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$correct_answer</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_message</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'math_question'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Your answer to the math question was incorrect'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This will check if what the user has input is correct against a temporary flash session.</p>
<p>Here is all of the controller code in full:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> Contact <span style="color: #000000; font-weight: bold;">extends</span> Controller <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'form_validation'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'math_question'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$questionOne</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">math_question</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">questionOne</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$questionTwo</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">math_question</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">questionTwo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_flashdata</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'questionOne'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$questionOne</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_flashdata</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'questionTwo'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$questionTwo</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'math_question'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;What is <span style="color: #006699; font-weight: bold;">{$questionOne}</span> + <span style="color: #006699; font-weight: bold;">{$questionTwo}</span>?&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_rules</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'math_question'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Math Question'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'callback_math_question'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">run</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'contact/form'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;success&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> math_question<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$user_answer</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'math_question'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$questionOne</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">flashdata</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'questionOne'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$questionTwo</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">flashdata</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'questionTwo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$correct_answer</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$questionOne</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$questionTwo</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$user_answer</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$correct_answer</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_message</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'math_question'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Your answer to the math question was incorrect'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>Create the view</h2>
<p>The last thing we need to do is create the view. Goto views and create a folder called contact, within that folder create a file called form.php.</p>
<p>Here is the code for form.php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">echo</span> validation_errors<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> form_open<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'contact'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
Name: &lt;input type=&quot;text&quot; name=&quot;name&quot; /&gt; &lt;br /&gt;
<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$math_question</span><span style="color: #000000; font-weight: bold;">?&gt;</span> &lt;br /&gt;
Answer: &lt;input type=&quot;text&quot; name=&quot;math_question&quot; /&gt; &lt;br /&gt;
&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Send!&quot; /&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">echo</span> form_close<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>On the first line we output the validation errors if there is any, on the second line we use the form helper to open the form tags and likewise for the bottom line where we close the form. $math_question is the variable that is passed in from the controller.</p>
<h2>Post your thoughts</h2>
<p>Let us know what you think of the tutorial and share your thoughts and contributions below in the comments.</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thetutorialblog.com/php/adding-security-to-codeigniter-forms-with-a-custom-library-class/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Easily and effectively display images with FancyBox</title>
		<link>http://www.thetutorialblog.com/general/easily-and-effectively-display-images-with-fancybox/</link>
		<comments>http://www.thetutorialblog.com/general/easily-and-effectively-display-images-with-fancybox/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 23:32:39 +0000</pubDate>
		<dc:creator>Wez Pyke</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Text Tutorials]]></category>
		<category><![CDATA[alternative]]></category>
		<category><![CDATA[fancybox]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[lightbox]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.thetutorialblog.com/?p=117</guid>
		<description><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	FancyBox is a plugin for jQuery that allows you to easily display images in the same window with a simple yet effective code. The plugin takes no time to set up and all that is required is that you include the jQuery javascript library within the pages that you are using the FancyBox plugin on. [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fgeneral%2Feasily-and-effectively-display-images-with-fancybox%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fgeneral%2Feasily-and-effectively-display-images-with-fancybox%2F&amp;source=wezpyke&amp;style=normal&amp;service=bit.ly" height="61" width="50" title="Easily and effectively display images with FancyBox" alt=" Easily and effectively display images with FancyBox" /><br />
			</a>
		</div>
<p><img class="alignleft size-full wp-image-118" title="fancybox" src="http://www.thetutorialblog.com/wp-content/uploads/2009/08/fancybox.png" alt="fancybox Easily and effectively display images with FancyBox" width="343" height="103" /><a href="http://fancybox.net/">FancyBox</a> is a plugin for <a href="http://www.jquery.com">jQuery</a> that allows you to easily display images in the same window with a simple yet effective code. The plugin takes no time to set up and all that is required is that you include the jQuery javascript library within the pages that you are using the FancyBox plugin on.</p>
<p>Features:</p>
<ul>
<li>Display single images</li>
<li>Create image galleries</li>
<li>Display iFrame</li>
<li>Execute Ajax</li>
<li>Include Flash, movies or audio files</li>
</ul>
<h2>Using FancyBox</h2>
<p>First of all we need to link to the jQuery and FancyBox file after we have downloaded.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;path-to-file/jquery.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;path-to-file/jquery.fancybox.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p><span id="more-117"></span><br />
Next we add the stylesheet that is included with FancyBox:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;link rel=&quot;stylesheet&quot; href=&quot;path-to-file/fancybox.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot;&gt;</pre></div></div>

<p>Then to link to an image we simply set the id of an image to "<i>single_image</i>":</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;a id=&quot;single_image&quot; href=&quot;image_big.jpg&quot;&gt;&lt;img src=&quot;image_small.jpg&quot; alt=&quot;&quot;/&gt;&lt;/a&gt;</pre></div></div>

<p>All that is left to do is execute the jQuery code when the DOM is loaded.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a#single_image&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fancybox</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>That is all the code that is needed to display a single image. To learn how to do things such as ajax calls, view the documentation for FancyBox <a href="http://fancybox.net/howto">here</a>.</p>
<h2>Other lightbox alternatives</h2>
<p>Is there another lightbox alternative that you have used that you would like to share with all the readers? Post a comment below.</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thetutorialblog.com/general/easily-and-effectively-display-images-with-fancybox/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>jQuery Form Validation</title>
		<link>http://www.thetutorialblog.com/video-tutorials/jquery-form-validation/</link>
		<comments>http://www.thetutorialblog.com/video-tutorials/jquery-form-validation/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 20:38:47 +0000</pubDate>
		<dc:creator>Wez Pyke</dc:creator>
				<category><![CDATA[Video Tutorials]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.thetutorialblog.com/?p=82</guid>
		<description><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	Create a form that requires the user to enter both a username and password. If the username field or password field is left blank then a message will be displayed. No related posts. Related posts brought to you by Yet Another Related Posts Plugin.


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fvideo-tutorials%2Fjquery-form-validation%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fvideo-tutorials%2Fjquery-form-validation%2F&amp;source=wezpyke&amp;style=normal&amp;service=bit.ly" height="61" width="50" title="jQuery Form Validation" alt=" jQuery Form Validation" /><br />
			</a>
		</div>
<p>Create a form that requires the user to enter both a username and password. If the username field or password field is left blank then a message will be displayed.</p>
<p><object type="application/x-shockwave-flash" width="512" height="399" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" ><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://blip.tv/scripts/flash/showplayer.swf" /><param name="flashvars" value="init=http://blip.tv/play/AYGN4GwA" /><embed src="http://blip.tv/play/AYGN4GwA" type="application/x-shockwave-flash" width="512" height="399" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thetutorialblog.com/video-tutorials/jquery-form-validation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery #1</title>
		<link>http://www.thetutorialblog.com/video-tutorials/jquery-1/</link>
		<comments>http://www.thetutorialblog.com/video-tutorials/jquery-1/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 22:45:40 +0000</pubDate>
		<dc:creator>Wez Pyke</dc:creator>
				<category><![CDATA[Video Tutorials]]></category>
		<category><![CDATA[animate]]></category>
		<category><![CDATA[blip]]></category>
		<category><![CDATA[blip.tv]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.thetutorialblog.com/?p=73</guid>
		<description><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	Learn how to use the animate function within the jQuery library to create an effect similar to the table of contents for the table of contents on codeigniter.com. Blip.tv Link Click to play No related posts. Related posts brought to you by Yet Another Related Posts Plugin.


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fvideo-tutorials%2Fjquery-1%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fvideo-tutorials%2Fjquery-1%2F&amp;source=wezpyke&amp;style=normal&amp;service=bit.ly" height="61" width="50" title="jQuery #1" alt=" jQuery #1" /><br />
			</a>
		</div>
<p>Learn how to use the animate function within the jQuery library to create an effect similar to the table of contents for the table of contents on codeigniter.com. </p>
<p><a href="http://thetutorialblog.blip.tv/file/2296444/">Blip.tv Link</a></p>
<p><span id="more-73"></span></p>
<p><center>															<script type="text/javascript" src="http://blip.tv/scripts/pokkariPlayer.js?ver=2008010901"></script>					<script type="text/javascript" src="http://blip.tv/syndication/write_player?skin=js&#038;posts_id=2312660&#038;source=3&#038;autoplay=true&#038;file_type=flv&#038;player_width=1024&#038;player_height=768"></script>
<div id="blip_movie_content_2312660">					<a rel="enclosure" href="http://blip.tv/file/get/Thetutorialblog-jQuery1834.flv" onclick="play_blip_movie_2312660(); return false;"><img title="Click to play" alt="Video thumbnail. Click to play" width="512" height="384" src="http://blip.tv/file/get/Thetutorialblog-jQuery1834.flv.jpg" border="0" title="Click to play" /></a>					<br />					<a rel="enclosure" href="http://blip.tv/file/get/Thetutorialblog-jQuery1834.flv" onclick="play_blip_movie_2312660(); return false;">Click to play</a>					</div>
<p>										</center></p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thetutorialblog.com/video-tutorials/jquery-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://blip.tv/file/get/Thetutorialblog-jQuery1652.mov" length="34276983" type="video/quicktime" />
<enclosure url="http://blip.tv/file/get/Thetutorialblog-jQuery1834.flv" length="32154787" type="video/x-flv" />
		</item>
		<item>
		<title>Boosting traffic to your website with submission websites</title>
		<link>http://www.thetutorialblog.com/general/boosting-traffic-to-your-website-with-submission-websites/</link>
		<comments>http://www.thetutorialblog.com/general/boosting-traffic-to-your-website-with-submission-websites/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 17:45:55 +0000</pubDate>
		<dc:creator>Wez Pyke</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[codebounce]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[graphic design]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[learn]]></category>
		<category><![CDATA[learnphp]]></category>
		<category><![CDATA[Photoshop]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[submission]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[tutorial submission]]></category>
		<category><![CDATA[tutorialized]]></category>
		<category><![CDATA[visitors]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.thetutorialblog.com/?p=49</guid>
		<description><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	There are many ways of getting traffic to your website such as with search engines, social network websites and telling friends. The best way that I have found besides search engines of getting traffic to your website is by submitting your tutorials to tutorial submission websites. There are tutorial websites that allow for submission of [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fgeneral%2Fboosting-traffic-to-your-website-with-submission-websites%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fgeneral%2Fboosting-traffic-to-your-website-with-submission-websites%2F&amp;source=wezpyke&amp;style=normal&amp;service=bit.ly" height="61" width="50" title="Boosting traffic to your website with submission websites" alt=" Boosting traffic to your website with submission websites" /><br />
			</a>
		</div>
<p>There are many ways of getting traffic to your website such as with search engines, social network websites and telling friends. The best way that I have found besides search engines of getting traffic to your website is by submitting your tutorials to tutorial submission websites.</p>
<p>There are tutorial websites that allow for submission of specific tutorials such as only PHP or Photoshop tutorials and there are websites that allow you to submit a lot of different types of tutorials to that website.</p>
<p><a href="http://www.codebounce.com" target="_blank"><img class="alignnone size-full wp-image-50" title="codebounce" src="http://www.thetutorialblog.com/wp-content/uploads/2008/11/codebounce.png" alt="codebounce Boosting traffic to your website with submission websites" width="315" height="58" /></a><br />
<a href="http://www.codebounce.com">CodeBounce</a> is one of the tutorial submission websites that allow you to submit a range of different tutorials. Its system is somewhat similar to that of Digg's. CodeBounce is a great website and is easy to get to grips with. They allow for the submission of ASP.NET, PHP, CSS, Photoshop, WordPress, Graphic Design, Web Design and Java.<br />
<a href="http://www.codebounce.com">Developer Links and Tutorials</a>.<br />
<span id="more-49"></span> </p>
<p><a href="http://www.learnphp.org"><img class="alignnone size-full wp-image-52" title="learnphp" src="http://www.thetutorialblog.com/wp-content/uploads/2008/11/learnphp.png" alt="learnphp Boosting traffic to your website with submission websites" width="256" height="83" /></a><br />
LearnPHP is a website that I recommend submitting your PHP tutorials too because I receive a lot of visitors from them and overall the website is easy to navigate and understand. They only allow for the submission of PHP tutorials as you can probably tell from the name.</p>
<p><a href="http://www.tutorialized.com/"></a><a href="http://www.tutorialized.com"><img class="alignnone size-full wp-image-56" title="tutorialized1" src="http://www.thetutorialblog.com/wp-content/uploads/2008/11/tutorialized1.png" alt="tutorialized1 Boosting traffic to your website with submission websites" width="325" height="85" /></a><br />
Tutorialized is a great website that allows for the submission of many different types of tutorials. Tutorialized has been a website that has been around for a long time and if you submit a tutorial to this website and you get accepted then expect quite a lot of hits from here as they have a lot of visitors.</p>
<p> </p>
<p>If there are any other websites that you like submitting tutorials too and have received a good amount of visitors from then share it with everyone and let us know by posting a comment.</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thetutorialblog.com/general/boosting-traffic-to-your-website-with-submission-websites/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

