
February 27th, 2002, 07:55 AM
|
|
Junior Member
|
|
Join Date: Jan 2002
Location: Vienna, Austria
Posts: 13
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
not jsp/javascript, but maybe it helps ...
Code:
$index = $q->params('i'); #first page is called with i=1
$max = ???; #number of rows
$MAXROWS = 10;
$end = $max;
$next = 0;
if (($max - $index) >= $MAXROWS) {
$end = $index + $MAXROWS - 1;
$next = 1;
}
#rows
for ($i = $index; $i <= $end; $i++) {
print $rows[$i - 1]; #if first elements index is 0
}
#prev-link
if ($index > 1) {
$j = $index - $MAXROWS;
if ($j < 1) {
$j = 1;
}
print "<a href='http://url?i=$j'>Prev</a>";
}
#direct links
if ($max > $MAXROWS) {
for ($i = 1; $i <= $max; $i = $i + $MAXROWS) {
if (($i >= $index) && ($i < ($index + $MAXROWS))) {
print " $i "; #actual page is not a link
} else {
print " <a href='http://url?i=$i'>$i</a> ";
}
}
}
#next link
if ($next) {
print "<a href='http://url?i=" . ($end + 1) . "'>Next</a>";
}
sorry, but i had no time to test the code. maybe you have to add somewhere a +/- 1 or so
Last edited by Hermetiker : February 27th, 2002 at 07:57 AM.
|