<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Sorting Your MySQL Results Set In PHP Using jQuery (And A More Traditional Approach)</title>
	<atom:link href="http://www.dougv.com/2009/06/13/sorting-your-mysql-results-set-in-php-using-jquery-and-a-more-traditional-approach/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dougv.com/2009/06/13/sorting-your-mysql-results-set-in-php-using-jquery-and-a-more-traditional-approach/</link>
	<description>ASP.NET, PHP, XML, JavaScript, Web geekery, Entrepreneurship</description>
	<lastBuildDate>Fri, 18 May 2012 10:23:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Doug Vanderweide</title>
		<link>https://www.dougv.com/2009/06/13/sorting-your-mysql-results-set-in-php-using-jquery-and-a-more-traditional-approach/#comment-1037</link>
		<dc:creator>Doug Vanderweide</dc:creator>
		<pubDate>Fri, 18 May 2012 10:23:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=2222#comment-1037</guid>
		<description>@gaixixon: tablesorter has a pagination plugin, available at the same link. Its drawback is that it will only allow you to sort what is on the screen, not the entire recordset.

Thus, you should go the PHP route and use LIMIT. So, for example, if you have 50 records per page, and you want to show page 15, you would need to calculate, and add to both the header and a new, page navigation footer row, the page you want to use, like this:

[php]
define(&#039;MYSQL_PAGE_SIZE&#039;, 50);

$curpage = $_GET[&#039;p&#039;];

if(!isset($curpage) &#124;&#124; !preg_match(&#039;/[0-9]{1,3}/&#039;, $curpage])) {
	$curpage = 1;
}

$minrecord = ($curpage - 1) * MYSQL_PAGE_SIZE;
$maxrecord = $minrecord + MYSQL_PAGE_SIZE;

$sql .= &quot; LIMIT $minrecord, $maxrecord&quot;;
[/php]</description>
		<content:encoded><![CDATA[<p>@gaixixon: tablesorter has a pagination plugin, available at the same link. Its drawback is that it will only allow you to sort what is on the screen, not the entire recordset.</p>
<p>Thus, you should go the PHP route and use LIMIT. So, for example, if you have 50 records per page, and you want to show page 15, you would need to calculate, and add to both the header and a new, page navigation footer row, the page you want to use, like this:</p>
<pre class="brush: php; title: ; notranslate">
define('MYSQL_PAGE_SIZE', 50);

$curpage = $_GET['p'];

if(!isset($curpage) || !preg_match('/[0-9]{1,3}/', $curpage])) {
	$curpage = 1;
}

$minrecord = ($curpage - 1) * MYSQL_PAGE_SIZE;
$maxrecord = $minrecord + MYSQL_PAGE_SIZE;

$sql .= &quot; LIMIT $minrecord, $maxrecord&quot;;
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: gaixixon</title>
		<link>https://www.dougv.com/2009/06/13/sorting-your-mysql-results-set-in-php-using-jquery-and-a-more-traditional-approach/#comment-1036</link>
		<dc:creator>gaixixon</dc:creator>
		<pubDate>Fri, 18 May 2012 09:56:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=2222#comment-1036</guid>
		<description>I have some more questions: AFAIK, the php output *all* the pages, and the jquery hide some pages, and show only one by one. What happen if i have say 100pages? Each time user visit the site, php output all the 100pages, and jquery actually show each page but the server still have to output the same information!
I hope you get my point.</description>
		<content:encoded><![CDATA[<p>I have some more questions: AFAIK, the php output *all* the pages, and the jquery hide some pages, and show only one by one. What happen if i have say 100pages? Each time user visit the site, php output all the 100pages, and jquery actually show each page but the server still have to output the same information!<br />
I hope you get my point.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gaixixon</title>
		<link>https://www.dougv.com/2009/06/13/sorting-your-mysql-results-set-in-php-using-jquery-and-a-more-traditional-approach/#comment-1035</link>
		<dc:creator>gaixixon</dc:creator>
		<pubDate>Fri, 18 May 2012 08:44:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=2222#comment-1035</guid>
		<description>Yay.. thank you Doug for the code. Especially the PHP one. I understand that it heavily hurts the server but this way make me understand the world easier than just two rows of jQuery :)
I have another question: is it possible to paginate the html output by jQuery? Currently I do this purely by PHP :)
gaixixon.</description>
		<content:encoded><![CDATA[<p>Yay.. thank you Doug for the code. Especially the PHP one. I understand that it heavily hurts the server but this way make me understand the world easier than just two rows of jQuery <img src='https://www.dougv.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
I have another question: is it possible to paginate the html output by jQuery? Currently I do this purely by PHP <img src='https://www.dougv.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
gaixixon.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Vanderweide</title>
		<link>https://www.dougv.com/2009/06/13/sorting-your-mysql-results-set-in-php-using-jquery-and-a-more-traditional-approach/#comment-1032</link>
		<dc:creator>Doug Vanderweide</dc:creator>
		<pubDate>Tue, 15 May 2012 00:44:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=2222#comment-1032</guid>
		<description>@Blake: Sure. Just code in whatever you want.</description>
		<content:encoded><![CDATA[<p>@Blake: Sure. Just code in whatever you want.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blake</title>
		<link>https://www.dougv.com/2009/06/13/sorting-your-mysql-results-set-in-php-using-jquery-and-a-more-traditional-approach/#comment-1031</link>
		<dc:creator>Blake</dc:creator>
		<pubDate>Mon, 14 May 2012 23:01:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=2222#comment-1031</guid>
		<description>Is there any way to put a row above the row that will have the links for sorting?  The  makes that row automatically be at the top but if I leave the  out then the sorting does not work.  Thanks!</description>
		<content:encoded><![CDATA[<p>Is there any way to put a row above the row that will have the links for sorting?  The  makes that row automatically be at the top but if I leave the  out then the sorting does not work.  Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>https://www.dougv.com/2009/06/13/sorting-your-mysql-results-set-in-php-using-jquery-and-a-more-traditional-approach/#comment-262</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Tue, 08 Feb 2011 18:28:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=2222#comment-262</guid>
		<description>Got it working already - I had made some typo&#039;s.. Thank you so much for posting this solution! :-D</description>
		<content:encoded><![CDATA[<p>Got it working already &#8211; I had made some typo&#8217;s.. Thank you so much for posting this solution! <img src='https://www.dougv.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>https://www.dougv.com/2009/06/13/sorting-your-mysql-results-set-in-php-using-jquery-and-a-more-traditional-approach/#comment-261</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Tue, 08 Feb 2011 00:50:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=2222#comment-261</guid>
		<description>Hi Doug, would you be willing to share a sample file? I&#039;m trying to get this to work, but the column headers aren&#039;t clickable, and I&#039;m quite lost here (still a PHP n00b).. Thanks!</description>
		<content:encoded><![CDATA[<p>Hi Doug, would you be willing to share a sample file? I&#8217;m trying to get this to work, but the column headers aren&#8217;t clickable, and I&#8217;m quite lost here (still a PHP n00b).. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Vanderweide</title>
		<link>https://www.dougv.com/2009/06/13/sorting-your-mysql-results-set-in-php-using-jquery-and-a-more-traditional-approach/#comment-260</link>
		<dc:creator>Doug Vanderweide</dc:creator>
		<pubDate>Wed, 02 Feb 2011 16:33:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=2222#comment-260</guid>
		<description>@Graeme: I&#039;m glad this works for you. Almost certainly your issue is related to jQuery not being able to properly identify the container in which the table you want to sort appears. When it comes to specific implementations of the code I offer here, I do provide support in exchange for a Wish list purchase. Check out the details under &quot;Need more help or want to say thanks,&quot; above. Thanks!</description>
		<content:encoded><![CDATA[<p>@Graeme: I&#8217;m glad this works for you. Almost certainly your issue is related to jQuery not being able to properly identify the container in which the table you want to sort appears. When it comes to specific implementations of the code I offer here, I do provide support in exchange for a Wish list purchase. Check out the details under &#8220;Need more help or want to say thanks,&#8221; above. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Graeme</title>
		<link>https://www.dougv.com/2009/06/13/sorting-your-mysql-results-set-in-php-using-jquery-and-a-more-traditional-approach/#comment-259</link>
		<dc:creator>Graeme</dc:creator>
		<pubDate>Wed, 02 Feb 2011 14:17:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=2222#comment-259</guid>
		<description>Hi - very clear instructions - worked a treat for me in one osCommerce site - found a problem with getting it to run in an iframe - it didn&#039;t matter where I inserted the include for the jquery files it looked as though the browser was unable to locate the js file (according to firebug) - any clues?</description>
		<content:encoded><![CDATA[<p>Hi &#8211; very clear instructions &#8211; worked a treat for me in one osCommerce site &#8211; found a problem with getting it to run in an iframe &#8211; it didn&#8217;t matter where I inserted the include for the jquery files it looked as though the browser was unable to locate the js file (according to firebug) &#8211; any clues?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: syabac</title>
		<link>https://www.dougv.com/2009/06/13/sorting-your-mysql-results-set-in-php-using-jquery-and-a-more-traditional-approach/#comment-258</link>
		<dc:creator>syabac</dc:creator>
		<pubDate>Tue, 06 Jul 2010 09:09:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=2222#comment-258</guid>
		<description>waw, very complete and clear code.
thanks for sharing.</description>
		<content:encoded><![CDATA[<p>waw, very complete and clear code.<br />
thanks for sharing.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

