Here's one of the scripts that I have tried. They all have the same problem when I use them. I noticed that when I make the select statemen like this ("select from $dbtable"); all the links work. When I make the select statement something like this
("select from $dbtable WHERE sex='$sex' and state='$state'and age='$age'");
I get zero results when I click on the links. It seems as if the select statement is not reading any variables.
<?
$server = "";
$userid = "";
$pass = "";
$database = "";
$dbtable = "";
$limit = 20;
$con = mysql_connect("$server","$userid","$pass") or die ("Huh? What Server");
$db = mysql_select_db("$database",$con) or die("I said WHAT database");
if (empty($offset) || $offset < 0) {
$offset=0;
}
if (empty($index)) $index=0; / This is to count the line index of the results /
$getrows = mysql_query("select * from $dbtable WHERE sex='$sex' and state='$state'and age='$age'", $con);
$numrows=mysql_num_rows($getrows);
$query = mysql_query("select * from $dbtable WHERE sex='$sex' and state='$state'and age='$age' limit $offset,$limit", $con);
while ($result=mysql_fetch_array($query)){
$index++; /* Increment the line index by 1 */
// Your results layout goes here
}
if ($numrows <= $limit) {
/ Added this statement so if the result shows less that or the
equal ammount of the limit to show nothing at all , to kill
the "1" that was just generated /
}
else {
// Don't display PREV link if on first page
if ($offset!=0) {
$prevoffset=$offset-$limit;
echo "<a onMouseOver=\"window.status='Previous $limit Results'; return true\"; href=\"$PHP_SELF?offset=$prevoffset&index=$prevoffset\"><B>[Previous]</B></a>   ";
} /* I particularly like having the [Previous] on the first page
if it has enough results to display at all with my mod , just helps
set the over all structure of the navigation system its self
so ill just add this to the above if statement */
else echo "<b><font color=666666>[Previous]</font></b>   ";
/* If its not to your likeing simply comment it out ;) */
// Calculate total number of pages in result
$pages = intval($numrows/$limit);
// $pages now contains total number of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
// Now loop through the pages to create numbered links
// ex. 1 2 3 4 5 NEXT
for ($i=1;$i<=$pages;$i++) {
// Check if on current page
if (($offset/$limit) == ($i-1)) {
// $i is equal to current page, so don't display a link
echo " <b><font color=666666>$i</font></b> ";
} else {
// $i is NOT the current page, so display a link to page $i
$newoffset=$limit*($i-1);
echo " <a onMouseOver=\"window.status='Page $i Results'; return true\"; href=\"$PHP_SELF?offset=$newoffset&index=$newoffset\"><B>$i</B></a> \n";
}
}
// Check to see if current page is last page
if (!((($offset/$limit)+1)==$pages) && $pages!=1) {
// Not on the last page yet, so display a NEXT Link
$newoffset=$offset+$limit;
echo "    <a onMouseOver=\"window.status='Next $limit Results'; return true\"; href=\"$PHP_SELF?offset=$newoffset&index=$newoffset\"><B>[Next]</B></a><p>\n";
} /* Im doing the same thing here as i did in the [Previous] above */
else echo "   <b><font color=666666>[Next]</font></b>";
}
mysql_close($con);
?>