title: PHP pagination after concatonation
body: <p>I'm new to pagination and am looking to display 10 topics per view_category.php page.</p>
  
  <p>On the index.php there are links to each category, leading to category.php?cid=1 (or whatever the category (cid) number is).</p>
  
  <p>How would I go about displaying 10 topics per page under each cid?</p>
  
  <p>This is the code I've experimented with thus far:</p>
  
  <pre><code>&lt;?php
  include('connect.php'); // Connects to the DB
  
  if(isset($_GET['page']))
  {
      $page = $_GET['page'];
      $page = mysql_real_escape_string($page);
  } else { 
     $page = 1;
  }
  $cid = $_GET['cid'];
  $result = mysql_query("SELECT * FROM topics");
  $rows = mysql_num_rows($result);
  
  $per_page = 5;
  
  $total_pages = ceil($rows/$per_page);
  
  echo "You are on page $page of $total_pages&lt;br&gt;";
  
  if($page !=1)
  {
      echo "&lt;a href='view_catagory.php?cid=".$cid."?page=1'&gt;First&lt;/a&gt; "." ";
      $previous = $page-1;
      echo "&lt;a href='view_catagory.php?cid=".$cid."?page=$previous'&gt;Previous&lt;/a&gt; "." ";
  }
  
  if(($page != 1) &amp;&amp; ($page != $total_pages))
  echo " | ";
  
  if ($page != $total_pages)
  {
      $next = $page+1;
      echo "&lt;view_catagory.php?cid=".$cid."?=$next'&gt;First&lt;/a&gt; "." ";
      echo "&lt;view_catagory.php?cid=".$cid."?=$total_pages'&gt;Last&lt;/a&gt; "." ";
  }
  echo "&lt;hr /&gt;";
  
  ?&gt;
  </code></pre>
  
  <p>.. this is how the categories are concatenated in index.php (all working fine, unsure if I'd need to do anything in here though.):</p>
  
  <pre><code>&lt;?php
      $sql = "SELECT * FROM categories ORDER BY category_title ASC";
      $res = mysql_query($sql) or die(mysql_error());
      $categories = "";
      if (mysql_num_rows($res) &gt; 0){
          while ($row = mysql_fetch_assoc($res)){
              $id = $row['id'];
              $title = $row['category_title'];
              $description = $row['category_description'];
      $categories .="&lt;center&gt;&lt;a href='view_catagory.php?cid=".$id."' class='cat_links'&gt;".$title." - &lt;font size'-1&gt;".$description."&lt;/font&gt;&lt;/a&gt;&lt;/center&gt;";
          }
          echo $categories;
      } else {
      echo "There are no categories.";
      }
      ?&gt;
  </code></pre>