<?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>PHP Tutorials Code Snippets and Php Tips &#187; php results pagination</title>
	<atom:link href="http://readytousesolutions.com/phpblog/tag/php-results-pagination/feed/" rel="self" type="application/rss+xml" />
	<link>http://readytousesolutions.com/phpblog</link>
	<description>PHP tutorials - Examples of the most useful scripts</description>
	<lastBuildDate>Thu, 23 Sep 2010 06:54:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>PHP Tutorial : Results Pagination</title>
		<link>http://readytousesolutions.com/phpblog/php-tutorial-results-pagination/</link>
		<comments>http://readytousesolutions.com/phpblog/php-tutorial-results-pagination/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 05:14:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Complete Scripts]]></category>
		<category><![CDATA[paginate]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[php links]]></category>
		<category><![CDATA[php navigation]]></category>
		<category><![CDATA[php paginate]]></category>
		<category><![CDATA[php paginate entries]]></category>
		<category><![CDATA[php paginate results]]></category>
		<category><![CDATA[php pagination]]></category>
		<category><![CDATA[php results pagination]]></category>
		<category><![CDATA[results pagination]]></category>
		<category><![CDATA[set a number of results per page]]></category>
		<category><![CDATA[split mysql results into page]]></category>

		<guid isPermaLink="false">http://www.crivionweb.com/phpblog/?p=284</guid>
		<description><![CDATA[A very usefull and common subject : php pagination. You need this when you have a lot of entries in the database and don&#8217;t want to show them in a single page, here comes the results pagination in php. This &#8230; <a href="http://readytousesolutions.com/phpblog/php-tutorial-results-pagination/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A very usefull and common subject : php pagination. You need this when you have a lot of entries in the database and don&#8217;t want to show them in a single page, here comes the results pagination in php. This works pretty simple, not that complex : firstly we calculate the total ammount of entries, then the numbers of page needed to show everthing, and, of course, how many results per page. Finaly, we&#8217;ll print out the entries and links for next, previous and page numbers.</p>
<pre class="php">
//include database connection (check previous posts to get this one)
include(&#039;dbConnection.php&#039;);
//get the number of total rows
$query = &quot;SELECT * FROM TableName&quot;;
$result = mysql_query($query);
// Number of records found
$num_record = mysql_num_rows($result);
// Number of results per page
$display = 5;
if(isset($_GET[&#039;page&#039;]) {
$currentPage = $_GET[&#039;page&#039;];
}else{
$currentPage = 1;
}
//last page
$lastPage = ceil($num_record/$display);
//limit in the query thing
$limitQ = &#039;LIMIT &#039; .($currentPage - 1) * $display .&#039;,&#039; .$display;
//normal query and print results
$query = &quot;SELECT * FROM TableName $limitQ&quot;;
$result = mysql_query($query);
//here you do your loop like
while($row=@mysql_fetch_object($result)) {
print &quot;$row-&gt;FieldName&quot;;
}
//pagination navigation (links)
//previous
if ($currentPage == 1) {
print &quot;Prev &quot;;
} else {
print &quot;<span class="htmlAnchorTag">&lt;a href=pagename.php?page=1&gt;</span>First page<span class="htmlAnchorTag">&lt;/a&gt;</span> &quot;;
$previousPage = $currentPage-1;
print &quot;<span class="htmlAnchorTag">&lt;a href=pagename.php?page=$previousPage&gt;</span>Previous<span class="htmlAnchorTag">&lt;/a&gt;</span>&quot;;
}
print &quot; { Page $currentPage of $lastPage } &quot;;
//for next pages links
if ($currentPage== $lastPage) {
print &quot;Next last&quot;;
} else {
$nextPage = $currentPage+1;
print &quot; <span class="htmlAnchorTag">&lt;a href=pagename.php?page=$nextPage&gt;</span>NEXT<span class="htmlAnchorTag">&lt;/a&gt;</span> &quot;;
print &quot; <span class="htmlAnchorTag">&lt;a href=pagename.php?page=$lastPage&gt;</span>LAST<span class="htmlAnchorTag">&lt;/a&gt;</span> &quot;;
}
?&gt;
</pre>
<p>Now you can use this pagination to split your mysql results into multiple webpages!</p>
]]></content:encoded>
			<wfw:commentRss>http://readytousesolutions.com/phpblog/php-tutorial-results-pagination/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

