Use $num as a global value across all pages, through GET, and use $i for a
per-script counter. Increase both in a loop, add some navigation, and
you're all set...
This should be a starting point...
<?
$total_num = 137;
$per_page = 25;
// find value of $num, or start from zero
if(isset($_GET['num'])) { $num = $_GET['num']; } else { $num = 0; }
$i = 0;
while( ($i < $per_page) && ($num < 137) )
{
// increase "global" counter
$num++;
// increase "local" counter
$i++;
// do something here 25 times
echo "{$i} - {$num} <br />";
}
$last = $_GET['num'] - $per_page;
if($num > $per_page) {
echo "<a href='{$_SERVER['PHP_SELF']}?num={$last}'>last {$per_page}</a>";
echo " | ";
}
if($num < $total_num) {
echo "<a href='{$_SERVER['PHP_SELF']}?num={$num}'>next {$per_page}</a>";
}
?>
Cheers,
Justin French
on 25/03/03 5:09 PM, Sebastian ([EMAIL PROTECTED]) wrote:
> Hello all.
>
> rather dumb question.
>
> I have a pagination system, 25 results per page, which are user comments, I
> want to put a number on each comment so i am doing something like:
>
> $num=$num + 1;
> $number = $num;
> echo $number;
>
> But when i switch to the next 25 results it starts counting from 1 again,
> LoL.
>
> So i have to use $_GET right? If so can someone give me an example.
>
> Thanks in advanced.
>
>
> cheers,
> - Sebastian
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php