PHP with pagination - I know I am almost there
<p>I have created a search of a database that produces an HTML table to display the results. The results display an article title, which is hyperlinked to its location on the server, as well as the author of the article.</p>

<p>All works fine until I set up pagination using an online script. The pagination returns 25 results, with navigation to next pages. All results are fine in first page, but it seems the search query is not carried to the other pages.</p>

<p>If another page is selected "2, 3, ..., last" it displays information from the entire mysql table, not the queried data.</p>

<p>I have set up sessions to carry the search term, but it does not seem to be working. I believe the issue is in my code used to display results.</p>

<p>The script I used had this as an example to display results, but I cannot get it to work with my current "while loop statement"  <strong>EXAMPLE BELOW</strong></p>

<pre><code>    if ($page &lt; $counter - 1) 
        $pagination.= "&lt;a href=\"$targetpage?page=$next\"&gt;next �&lt;/a&gt;";
    else
        $pagination.= "&lt;span class=\"disabled\"&gt;next �&lt;/span&gt;";
    $pagination.= "&lt;/div&gt;\n";       
}
?&gt;

&lt;?php
    while($row = mysql_fetch_array($result))
    {

    // Your while loop here

    }
?&gt;

&lt;?=$pagination?&gt;
</code></pre>

<p>This is the last bit of script <strong>I HAVE USED</strong>, used to display the data.  </p>

<pre><code>&lt;h2&gt;Results&lt;/h2&gt;

&lt;table border="0" cellpadding="5"&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;div align="center"&gt;&lt;strong&gt;Title&lt;/strong&gt;&lt;/div&gt;&lt;/td&gt;
    &lt;td&gt;&lt;div align="center"&gt;&lt;strong&gt;Author&lt;/strong&gt;&lt;/div&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;?php do { ?&gt;

&lt;tr&gt;
  &lt;td&gt;&lt;?php echo  '&lt;a href="' . 'http:filelocation' . $row['pdf_path'] . '" target="_new"&gt;' .$row['pdf_title'] . '&lt;/a&gt;'; 
 ?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;?php echo $row['author'] ;?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;div align="center"&gt;&lt;?php echo $row['pages']; ?&gt;&lt;/div&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;?php } 

while ($row = mysql_fetch_array($sql))

 ?&gt;
</code></pre>

<p></p></p>



<p>I am using a "do while" statement to get data and display results, but do not know how to add the "while($row = mysql_fetch_array($result))" with proper syntax.</p>

<p>Please help!</p>
