how to make next and previous page
Posted: Wed Jun 22, 2005 8:02 pm
Hi everybody
I tried to print my array so I can have many page from my array. I want the user can see next page and previous page by clicking linking page.I believe that this is logic problem instead of PHP problem.
My problem is my page cannot move in final page-1
Thanks
I tried to print my array so I can have many page from my array. I want the user can see next page and previous page by clicking linking page.I believe that this is logic problem instead of PHP problem.
Code: Select all
<?php
$page[30];
for($i=0;$i<30;$i++){
$page[$i] = $i;
}
$k=0;
$k = $_GET['k'];
echo "<br><br><br><br>";
$y=$k*5;
$z=$y+5;
for($i=$y;$i<$z;$i++){
echo $page[$i];
echo "<br>";
}
echo "<br>";
$x = (count($page)/5)-1;
if($k<$x){
$k++;
$address="http://localhost/testpage.php?k=$k";
echo "<a href=$address>";
echo "next\n\n\n";
echo "</a>";
echo "<<<<< >>>>>>";
}
if($k>=$x||$k>1){
$w = $k-2;
$address="http://localhost/testpage.php?k=$w";
echo "<a href=$address>";
echo "\n\n\nprevious";
echo "</a>";
}
?>Thanks