Forum Moderators: coopster
The if statements that produce these functions are as follows:
// links to previous results
if ($s>=1) { // bypass PREV link if s is 0
$prevs=($s-$limit);
print "<a href=\"$PHP_SELF?s=$prevs&q=$var\">
PREV</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=\"$PHP_SELF?s=$news&q=$var\">;</a>";
echo "<a href=\"$PHP_SELF?s=$news&q=$var\"><b>¦. NEXT</b></a>";
}
thanx
imagus
<form method="get" action="<?php echo $_SERVER['PHP_SELF']?>">
<input type="hidden" name="q" value="1">
<input type="submit" value="Previous">
</form>
Or you could just use normal anchor links..
<a href="<?php echo $_SERVER['PHP_SELF']?>?q=1">previous</a>
<a href="<?php echo $_SERVER['PHP_SELF']?>?q=3">next</a>
In both cases you can get the value of q by using $_GET['q']. Don't just use $q as this only works if register_globals is set on (which is usually a bad thing!).
Incidentally, if you are using this technique to link lots of pages together then you should also setup the <link> tags [w3.org] in <head>.
e.g.
<link rel="contents" rev="subsection" href="index.html">
<link rel="prev" rev="next" href="page_3.html">
<link rel="next" rev="prev" href="page_5.html">
Then users of decent browsers (like Opera) will be able to browse your pages using the browser controls. Plus search engines should index the pages better.