Numbering results drawn out from database using pagination - PHP
<p>Ok my is this I am creating a script for a website am designing that will using pagination to draw quotes out from database,</p>

<p>I have done that part quite well, setting up the pagination class and actually making it to print out the results, but I have been trying to make it print with a numbering system - as in each. </p>

<p>I want each quote to have its own number like:</p>

<ol>
<li>"One cannot overrun his shadow";</li>
<li>"foo is not fool, just used in php"</li>
<li><p>"so on and so forth";</p>

<p>Look at my class:</p>

<pre><code>class pagination extends cleanPost{

var $p=1, $max_r,$limits;
var $count_all=0,$sql,$total,$table,$totalres,$totalpages;
var $r,$i;
var $show=10;



function setMax($max_r){

       $this-&gt;p = $this-&gt;clean($_GET['p']);
       $this-&gt;max_r = $max_r;

        if(empty($this-&gt;p))
        {
             $this-&gt;p = 1;
        }

       $this-&gt;limits = ($this-&gt;p - 1) * $this-&gt;max_r;

    }  
function setData($table){

   $this-&gt;table = $table;
   $this-&gt;sql = "SELECT * FROM ".$this-&gt;table." LIMIT ".$this-&gt;limits.",".$this-&gt;max_r."";
   $this-&gt;sql = mysql_query($this-&gt;sql) or die(mysql_error());
   $this-&gt;total = "SELECT * FROM ".$this-&gt;table."";
   $this-&gt;totalres =  mysql_query($this-&gt;total) or die(mysql_error());
   $this-&gt;count_all = mysql_num_rows($this-&gt;totalres); // count all the rows
   $this-&gt;totalpages = ceil($this-&gt;count_all / $this-&gt;max_r); // work out total pages 
}  



function displayLinks($show){

    $this-&gt;show = $show; // How many links to show

    echo "&lt;br&gt;&lt;br&gt;";

    if($this-&gt;p &gt; 1) // If p &gt; then one then give link to first page
    {
        $pagination .= "&lt;div class=\"pagination\"&gt;
         &lt;a href=?p=1&gt; [first] &lt;/a&gt;  ";    
    }
    else
    { // else show nothing
        $pagination .= "&lt;div class=\"pagination\"&gt;"."";
}
if($this-&gt;p != 1)
    { // if p aint equal to 1 then show previous text

        $previous = $this-&gt;p-1;

    $pagination .= "&lt;a href=?p=$previous&gt;«prev&lt;/a&gt;";

}
else
    { //else show nothing
    $pagination.= "&lt;span class=\"disabled\"&gt;first&lt;/span&gt;"."";
} 
for($i =1; $i &lt;= $this-&gt;show; $i++) // show ($show) links
{

        if($this-&gt;p &gt; $this-&gt;totalpages)
            { // if p is greater then totalpages then display nothing
            echo "";

    }
    else if($_GET["p"] == $this-&gt;p)
            { //if p is equal to the current loop value then dont display that value as link
               $pagination .= $this-&gt;p ;
    }
    else{
               $pagination .= " &lt;a href=?p=".$this-&gt;p."&gt; ".$this-&gt;p." &lt;/a&gt;"; // else display the rest as links
    }

    $this-&gt;p++; //increment $p  
}



if($_GET["p"] == $this-&gt;totalpages)
    {// if page is equal to totalpages then  dont display the last page at the end of links
   $pagination.= "&lt;span class=\"disabled\"&gt;last&lt;/span&gt;"."";
}
else  if($_GET["p"] != $this-&gt;totalpages)

{
// $pagination .= "..."; // display dots   
#   $pagination .= "&lt;a href=?p=".$this-&gt;totalpages."&gt;  ".$this-&gt;totalpages." &lt;/a&gt;"; 
}
else { // else display the last page link after other ones

}
if($_GET["p"] &lt; $this-&gt;totalpages)// if p is less then total pages then show next link
{
    $next = $_GET["p"] + 1;
    $pagination .= "&lt;a href=?p=$next&gt; next»&lt;/a&gt;"; 
    $pagination.= "&lt;a href=?p=".$this-&gt;totalpages."&gt; [last] &lt;/a&gt;"."";   
}
  $pagination.= "&lt;/div&gt;\n";            
echo $pagination;
</code></pre>

<p>}  </p>

<p>//////////
and this is my quote display page</p>

<pre><code>$page= new pagination;
  $page-&gt;setMax(5);//set the maximum quote shown per page
  $page   -&gt;setData("quotes");
   $page  -&gt;display();

echo "&lt;table border=1 width=100%&gt;";
  while ($row = mysql_fetch_array($page-&gt;sql)) 
  { 

    echo  $num_results = mysql_num_rows($page-&gt;sql);
    echo "&lt;tr&gt;";

  for ($i=0; $i &lt;$num_results; $i++)
{
echo "&lt;td&gt;";
 $num_found = $i + 1;

 echo $num_found.$row['ngwaquote'];
  echo "&lt;/td&gt;";
 }
echo "&lt;/tr&gt;";

  }
  echo "&lt;/table&gt;&lt;p&gt;";
   $page  -&gt;displayLinks(4) ;
</code></pre>

<p>the results am getting is that if i click on the first number in the pagination link
to give me
quote.html?p=1</p>

<p>I get them to list it serially
page:1
1[quote]A rolling stone gathers no moss.[/quote]<br>
2[quote]A rolling stone gathers no moss.[/quote]<br>
3[quote]A rolling stone gathers no moss.[/quote]<br>
4[quote]A rolling stone gathers no moss.[/quote]<br>
5[quote]A rolling stone gathers no moss.[/quote]</p>

<p>but the other page quote.html?p=2 <strong>instead of starting from</strong>
page:2
6[qoute]nothing[/quote]
7[quote]A rolling stone gathers no moss.[/quote]</p>

<p><strong>rather</strong> starts counting from one again
page:1
1[qoute]nothing[/quote]
2[quote]A rolling stone gathers no moss.[/quote]</p>

<p>I want it to appear like we have in BBC FOOTBALL blogs
where comment page number 2 starts from 101
instead of starting all over from 1 again</p>

<p>I hope my question is not too long to understand, if that I am sorry just felt like posting them all for better understanding.</p></li>
</ol>
