I understand how to create how a "Previous" and "Next". I used the following script:
<?php
//The Required Files to access the data base
require("../../../includes/configs/config.cfg");
require("../../../includes/configs/select_db.cfg");
//The Required Files to access the data base
// This sets the offset page so it starts up on page one //
if(!isset($_GET['offset'])) $_GET['offset'] = 0;
// This sets the offset page so it starts up on page one //
// The query for what will be displayed //
$poster_sql = "SELECT * FROM poster WHERE category=" .$_GET['show_cat'] ." ORDER BY code LIMIT ".$_GET['offset'] .", 20";
// The query for what will be displayed //
$poster_results = mysql_query($poster_sql) or die(mysql_error());
//we add this line because we need to know the number of rows//
$poster_rows = mysql_num_rows($poster_results);
//we add this line because we need to know the number of rows//
// The query for what is the total of results //
$total_sql = "SELECT * FROM poster WHERE category=" .$_GET['show_cat'];
// The query for what is the total of results //
//This Query is meant to give the total amount of results given for that given category//
$total_results = mysql_query($total_sql) or die (mysql_error());
//This Query is meant to give the total amount of results given for that given category//
$nrow = mysql_num_rows($total_results);
while ($poster = mysql_fetch_array($poster_results))
{
echo "<br>"
.$poster['code'];
}
echo"<br>";
//These are the next and Previous Buttons//
if($_GET['offset'] > 0)
echo "<a href=\"" . $PHP_SELF . "?show_cat=" .$_GET['show_cat'] ."&offset=" . ($_GET['offset'] - 20) .
"\">Previous</a> |\n";
if($nrow > ($_GET['offset'] + 10))
echo "<a href=\"" . $PHP_SELF . "?show_cat=" .$_GET['show_cat'] ."&offset=" . ($_GET['offset'] + 20) .
"\">Next</a><BR>\n";
//These are the next and Previous Buttons//
?>
You can also see it in action here:
http://69.13.156.225/test/includes/main_stage_items/results/test.php?show_cat=1
I do want to be able to expand on this by having single pages like so:
< previous | 1 | 2 | 3 | etc... | Next >
how can I achieve this? I'm currently working on it, so there will be updates to this post but I also wanted to some more input on this subject from other people. Thanks in advance..