<?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>Tampa Site Design &#187; php</title>
	<atom:link href="http://www.tampasitedesign.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tampasitedesign.com</link>
	<description>Chronicles of Website Design</description>
	<lastBuildDate>Sun, 08 Aug 2010 19:36:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Line Breaks in Textarea with PHP</title>
		<link>http://www.tampasitedesign.com/line-breaks-in-textarea-with-php/</link>
		<comments>http://www.tampasitedesign.com/line-breaks-in-textarea-with-php/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 19:38:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[line breaks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[textarea]]></category>

		<guid isPermaLink="false">http://www.tampasitedesign.com/?p=60</guid>
		<description><![CDATA[There seems to be a  lot of confusion surrounding line breaks. You&#8217;re probably familiar with this:
\r\n
This is a line break, right? Well it can be. It depends on if it&#8217;s processed as normal text or not.
Let&#8217;s say a user is submitting a form and in the textarea, they add some line breaks. Let&#8217;s say they [...]]]></description>
			<content:encoded><![CDATA[<p>There seems to be a  lot of confusion surrounding line breaks. You&#8217;re probably familiar with this:</p>
<p>\r\n</p>
<p>This is a line break, right? Well it can be. I<strong>t depends on if it&#8217;s processed as normal text or not.</strong></p>
<p>Let&#8217;s say a user is submitting a form and in the textarea, they add some line breaks. Let&#8217;s say they miss a field and  you have the form printing out it&#8217;s own POST values (so they don&#8217;t accidentally lose anything), like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;textarea cols=&quot;32&quot; rows=&quot;6&quot; name=&quot;description&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/textarea&gt;</pre></div></div>

<p>This is pretty simple, it&#8217;s just printing out the value of the posted description variable. But like I said a minute ago, if they had put line breaks in their textarea, their information will be posted in the textarea again, but it will look like this:</p>
<p>Information on Line 1\r\nInformation on Line 2</p>
<p>The problem here is that the \r\n is getting changed to normal text. To change it back, we replace it with itself, but with double quotes, returning it back to code as opposed to normal text. Here&#8217;s the final result:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;textarea name=&quot;description&quot; rows=&quot;6&quot; cols=&quot;32&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'\r\n'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/textarea&gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.tampasitedesign.com/line-breaks-in-textarea-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Next and Previous Buttons for Search Query Results</title>
		<link>http://www.tampasitedesign.com/php-next-and-previous-buttons-for-search-query-results/</link>
		<comments>http://www.tampasitedesign.com/php-next-and-previous-buttons-for-search-query-results/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 19:29:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[buttons]]></category>
		<category><![CDATA[next]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[previous]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[results]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://www.tampasitedesign.com/?p=17</guid>
		<description><![CDATA[What we&#8217;re talking about today is how to make those Next, Previous, and Number buttons for search results&#8230;

Usually found at the bottom of sites like Google and eBay. There&#8217;s two pieces of data we need:

Start At / Offset Value (usually set in the URL)
Limit (set internally or in the URL)

Being we only need these two [...]]]></description>
			<content:encoded><![CDATA[<p>What we&#8217;re talking about today is how to make those Next, Previous, and Number buttons for search results&#8230;
<p><img src="http://www.tampasitedesign.com/images/search_results.gif" alt="search results php" /></p>
<p>Usually found at the bottom of sites like Google and eBay. There&#8217;s two pieces of data we need:</p>
<ol>
<li>Start At / Offset Value (usually set in the URL)</li>
<li>Limit (set internally or in the URL)</li>
</ol>
<p>Being we only need these two variables, you might think this is a pretty simple task, but creating some well-working links takes a fair bit of code. For this example, we&#8217;ll define the limit internally, but still use dynamic code so it could be used as a GET variable.</p>
<p>The first issue we have in defining links to a different offset is in the URL itself:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">index<span style="color: #339933;">.</span>php?keywords<span style="color: #339933;">=</span>tampawebsitedesign<span style="color: #339933;">&amp;</span>start_at<span style="color: #339933;">=</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">&amp;</span>order_by<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span></pre></div></div>

<p>As you can see here, our start_at variable is equal to 10, which is what we&#8217;ll put in our sql string. The problem is when they hit the next page button that sets it to 20. This impacts your links because you have to securely redefine the offset variable without loosing the other variables. Here&#8217;s how we would do that:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// get the current URL</span>
<span style="color: #000088;">$current_url</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTPS'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot;https://&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SERVER_NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;http://&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SERVER_NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// replace the start_at variable and value</span>
<span style="color: #000088;">$pattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/\&amp;start_at=[0-9]*/'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$back_forward_url</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #000088;">$current_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Here we&#8217;ve basically stripped our start_at variable and value from the URL. Moving forward, we need to generate our Next and Previous buttons. This part is pretty simple:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$start_at</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'start_at'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// set the start_at variable equal to the URL value</span>
<span style="color: #000088;">$limit_num</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// set the limit equal to 10 (or whatever you want)</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// calculate the previous amount and link</span>
<span style="color: #000088;">$previous_amt</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$start_at</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$limit_num</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$previous_link</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;a href=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$back_forward_url</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;start_at='</span><span style="color: #339933;">.</span><span style="color: #000088;">$previous_amt</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;Previous&lt;/a&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// calculate the next amount and link </span>
<span style="color: #000088;">$next_amt</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$start_at</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$limit_num</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$next_link</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;a href=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$back_forward_url</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;start_at='</span><span style="color: #339933;">.</span><span style="color: #000088;">$next_amt</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;Next&lt;/a&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// if statements which set the links equal to nothing</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$start_at</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$previous_link</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$start_at</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$limit_num</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;=</span> <span style="color: #000088;">$total_results</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$next_link</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>At this point we have our Next and Previous button variables taken care of. Now we need to make the numbers in the middle. Something to note, however, is that if you have 100 pages of results returned, we don&#8217;t want to print out 100 numbers, we only want to print out 9 or 10 or around there. So we need to install a range of if statements that will make sure we put in the right amount.</p>
<p>The first step is to create a function which our total pages and current page can calculate from:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// shared function for calculations</span>
<span style="color: #000000; font-weight: bold;">function</span> find_page<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tr</span><span style="color: #339933;">,</span><span style="color: #000088;">$ln</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$pages_total</span> <span style="color: #339933;">=</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tr</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$ln</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// intval rounds any decimal down to its integer value</span>
	<span style="color: #000088;">$match_results</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pages_total</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$ln</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$match_results</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$tr</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000088;">$pages_total</span><span style="color: #339933;">--;</span> <span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$pages_total</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">// find total pages</span>
<span style="color: #000088;">$pages_total</span> <span style="color: #339933;">=</span> find_page<span style="color: #009900;">&#40;</span><span style="color: #000088;">$total_results</span><span style="color: #339933;">,</span><span style="color: #000088;">$limit_num</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// find current page</span>
<span style="color: #000088;">$curr_page</span> <span style="color: #339933;">=</span> find_page<span style="color: #009900;">&#40;</span><span style="color: #000088;">$start_at</span><span style="color: #339933;">,</span><span style="color: #000088;">$limit_num</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span></pre></div></div>

<p>Next, we put in our if statements to set two new variables: $page_link and $loop.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pages_total</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">9</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$page_link</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$loop</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$pages_total</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curr_page</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">4</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$pages_total</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$page_link</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$pages_total</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$loop</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</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;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curr_page</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">9</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$page_link</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$loop</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</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: #000088;">$page_link</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$curr_page</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$loop</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Just about done! Now, we&#8217;ll loop through and save our links to a variable called $middle_links. I&#8217;ve taken the extra step to add in a styling class for an active link versus a non-active link.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$loop</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$page_start_at</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$page_link</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$limit_num</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$limit_num</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curr_page</span><span style="color: #339933;">==</span><span style="color: #000088;">$page_link</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #339933;">;</span><span style="color: #000088;">$link_class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'page_btn_active'</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: #000088;">$link_class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'page_btn'</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$middle_links</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;a href=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$back_forward_url</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;start_at='</span><span style="color: #339933;">.</span><span style="color: #000088;">$page_start_at</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; class=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$link_class</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$page_link</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/a&gt; | '</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$page_link</span><span style="color: #339933;">++;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Finally, we&#8217;ll put everything together and print it out. We have to do one last check before our print which is taking off the extra &#8221; | &#8221; from our loop if there is no Next button. You can also see that we&#8217;ve added a div to style the entire link bar.</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;">$next_link</span><span style="color: #339933;">==</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$middle_links</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$middle_links</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,-</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// take out the extra &quot; | &quot; if we have no Next button</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">print</span> <span style="color: #0000ff;">'&lt;div id=&quot;page_link_bar&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$previous_link</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">.</span><span style="color: #000088;">$middle_links</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">.</span><span style="color: #000088;">$next_link</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/div&gt;'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// put everything together</span></pre></div></div>

<p>There you have it! </p>
<p>Some hints to help you along as well:</p>
<ul>
<li>If the start_at value is not set in the URL, you need to set that to 0</li>
<li>Always do verification on your REQUEST (GET &amp; POST) variables. is_numeric() function works well for the start_at variable.</li>
<li>To make it work, you&#8217;ll just append your variables into your MySQL statement using LIMIT.

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">SELECT <span style="color: #339933;">*</span> WHERE id<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span> ORDER BY id DESC LIMIT <span style="color: #000088;">$start_at</span><span style="color: #339933;">,</span><span style="color: #000088;">$limit_num</span></pre></div></div>

</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.tampasitedesign.com/php-next-and-previous-buttons-for-search-query-results/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

