title: PHP - MySQL query with Pagination
body: <p>How would I go about making a pagination script for this MySQL &amp; PHP query.</p>
  
  <pre><code>if (isset($_GET['c'])) {
  $c = $_GET['c'];
  }
  
  $query = mysql_query("SELECT * FROM Categories WHERE category = '$c' ");
  
          WHILE($datarows = mysql_fetch_array($query)):
  
          $id = $datarows['id'];
          $category = $datarows['category'];
          $code = $datarows['code'];
  
          endwhile;
  
  $query2 = mysql_query("SELECT * FROM Games WHERE category = '$code' ");
  
  WHILE($datarows_cat = mysql_fetch_array($query2)):
  
          $title = $datarows_cat['title'];
          $description = $datarows_cat['description'];
          $imgurl = $datarows_cat['image_name'];
          $category = $datarows_cat['category'];
          $views = $datarows_cat['view_count'];
          $pagename = $datarows_cat['pagename'];
                  $featured = $datarows_cat['featured'];
  
  if ($featured =="1") {$f = "&lt;img src='http://my-site.com/images/star.png' width='13px' title='Featured Game' /&gt; Featured"; } else {$f = "";}
                      if(is_int($views/2)) {
  $views = $views / 2;
  } else { $views = $views / 2 + .5; }
  
  if (strlen($description) &gt; 95) {
      $desc= substr($description,0,95);
      $desmod = "$desc...&lt;br/&gt;&lt;a href=\"http://my-site.com/$pagename#1\" title=\"$description\"&gt;- Read More&lt;/a&gt;";
      }
  else {$desmod = "$description";}
  
          echo "$f - &lt;a href=\"http://my-site.com/$pagename\"&gt;$title - $desmod&lt;/a&gt;&lt;br/&gt;";
  
  endwhile;
  </code></pre>
  
  <p>And when I visit <a href="http://my-site.com/categories/Action" rel="nofollow">http://my-site.com/categories/Action</a> for instance, The code looks up that category in my category table, then once it gets the unique code for that category, It runs another query to find all games in another table with that category code. Currently, however, I have 200+ games loading for a single category which causes a great amount of loading time.</p>
  
  <p>Thanks for your help!</p>