I have a problem that I've spent countless hours on and I'm more than certain this is a obviuos issue to an expert but I am still learning. I have a paging script that I have modified to display a certian amount of records per page. But when I click on the next link , no new result are displayed it keep displaying the same result. Here is a sample of the script
[PHP]
<?php include('hdb.html'); ?>
<?php
// Get the search variable from URL
$var = @$_GET['category'] ;
$trimmed = trim($var); //trim whitespace from the stored variable
// rows to return
$limit=2;
// check for an empty string and display a message.
if ($trimmed == "")
{
echo "<p class=T1>Please enter a search...</p>";
exit;
}
// check for a search parameter
if (!isset($var))
{
echo "<p class=T1>We dont seem to have a search parameter!</p>";
exit;
}
//connect to your database ** EDIT REQUIRED HERE **
mysql_connect("xxxxx","xxxxxxx","xxxxxx"); //(host, username, password)
//specify database ** EDIT REQUIRED HERE **
mysql_select_db("xxxxxxxxx") or die("Unable to select database"); //select which database we're using
// Build SQL Query
$query = "select * from pix where category like \"%$trimmed%\"
order by category, pid, albumname, "; // EDIT HERE and specify your table and field names for the SQL query
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);
// If we have no results, offer a google search as an alternative
if ($numrows == 0)
{
echo "<h4>Results</h4>";
echo "<p class=T1>Sorry, your search: "" . $trimmed . "" returned zero results</p>";
// google
echo "<p class=T1><a href=\"http://www.google.com/search?q="
. $trimmed . "\" target=\"_blank\" title=\"Look up
" . $trimmed . " on Google\">Click here</a> to try the
search on google</p>";
}
// next determine if s has been passed to script, if not use 0
if (empty($s)) {
$s=0;
}
// get results
$query .= " limit $s,$limit";
$result = mysql_query($query) or die("Couldn't execute query");
// display what the person searched for
echo '<center><table width="550" border="0" cellspacing="1" cellpadding="2" bgcolor="#Ffffff"><tr>';
echo '<td width=230 class=T1>';
echo "<p class=T1>Your searched for: "" .$var . ""</p>";
echo '</td>
<td align=right width=335 padding="3" bgcolor=#eoeccc class=T1>
//html goes here
</td>
</tr></table></center>';
// begin to show results set
echo "";
$count = 1 + $s ;
// now you can display the results returned
while ($row= mysql_fetch_array($result)) {
$state = stripslashes($row["state"]);
$pid= stripslashes($row['pid']);
$albumname= stripslashes($row['albumname']);
echo '<center><table width="550" border="0" cellspacing="1" cellpadding="2" bgcolor="#F7F7F7"><tr>
<td onmouseover="this.className=\'bgcl\';" onmouseout="this.className=\'gb2\';" width=330 align=top bgcolor=#Ffffff class=T1>
//html from output goes here
</td>
</tr>';
}
echo "</table></center>";
$count++ ;
$currPage = (($s/$limit) + 1);
//break before paging
echo "<br />";
// next we need to do the links to other results
if ($s>=1) { // bypass PREV link if s is 0
$prevs=($s-$limit);
print " <a href=\"".$_SERVER['PHP_SELF']."??s=$prevs&category=$var\"><<
Prev 10</a>  ";
}
// calculate number of pages needing links
$pages=intval($numrows/$limit);
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
// check to see if last page
if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {
// not last page so give NEXT link
$news=$s+$limit;
echo " <a href=\"".$_SERVER['PHP_SELF']."?s=$news&category=$var\">Next 10 >></a>";
}
$a = $s + ($limit) ;
if ($a > $numrows) { $a = $numrows ; }
$b = $s + 1 ;
echo "<center><p class=T1>Showing results $b to $a of $numrows</p></center>";
?>
<?php include('footer.html'); ?>
[/PHP]
I've already modified the php self function to work properly but the info being pass back to page when next link is clicked is not envoking the script to display the next set of records