how can i make my pages links look like this when i want to another page
eg: <- Previous [1] [2] [3] [4] [5] Next ->
please help me out on this
eg: <- Previous [1] [2] [3] [4] [5] Next ->
please help me out on this
echo '<-< <a href="'.$_server['php_self'].'?page='.$page-1.'">Previous </a>';
for ($i = $page; $i <= $page+5; $i++) {
echo '<a href="'.$_server['php_self'].'?page='.$i.'">['.$i.'] </a> ';
}
echo '<a href="'.$_server['php_self'].'?page='.$page+1.'">Next -> </a>';
echo '<-< <a href="'.$_server['php_self'].'?page='.$page-1.'">Previous </a>';
for ($i = $page; $i <= $page+5; $i++) {
echo '<a href="'.$_server['php_self'].'?page='.$i.'">['.$i.'] </a> ';
}
echo '<a href="'.$_server['php_self'].'?page='.$page+1.'">Next -> </a>';
if($page>1){
$ppage = $page-1;
echo "<a href=\"index.php?page=$ppage\">«Prev</a> ";
}
$capped_pages = $total_pages-4;
if($pages<$capped_pages){
for ($i = $ppage; $i <= ($page+5); $i++) { //previous page added here also ...so if on page 3 it shows pages 23456
echo "<a href=\"index.php?page=$i\">[$i] </a> ";
}
}
else if($page==1){
for ($i = $page; $i <= ($page+5); $i++) {
echo "<a href=\"index.php?page=$i\">[$i] </a> ";
}
}
else{
for ($i = ($total_pages-5); $i <= ($page+5); $i++) { //show total pages (dont go over (capped))
echo "<a href=\"index.php?page=$i\">[$i] </a> ";
}
}
if($page<$total_pages){
$npage = $page+1;
echo "<a href=\"index.php?page=$npage\">Next»</a>";
}
if($page>1){
$ppage = $page-1;
echo "<a href=\"index.php?page=$ppage\">«Prev</a> ";
}
$capped_pages = $total_pages-4;
if($pages<$capped_pages){
for ($i = $ppage; $i <= ($page+5); $i++) { //previous page added here also ...so if on page 3 it shows pages 23456
echo "<a href=\"index.php?page=$i\">[$i] </a> ";
}
}
else if($page==1){
for ($i = $page; $i <= ($page+5); $i++) {
echo "<a href=\"index.php?page=$i\">[$i] </a> ";
}
}
else{
for ($i = ($total_pages-5); $i <= ($page+5); $i++) { //show total pages (dont go over (capped))
echo "<a href=\"index.php?page=$i\">[$i] </a> ";
}
}
if($page<$total_pages){
$npage = $page+1;
echo "<a href=\"index.php?page=$npage\">Next»</a>";
}
if($page>1){
$ppage = $page-1;
echo "<a href=\"index.php?page=$ppage\">«Prev</a> ";
}
$capped_pages = $total_pages-4;
if($pages<$capped_pages){
for ($i = $ppage; $i <= ($page+5); $i++) { //previous page added here also ...so if on page 3 it shows pages 23456
echo "<a href=\"index.php?page=$i\">[$i] </a> ";
}
}
else if($page==1){
for ($i = $page; $i <= ($page+5); $i++) {
if($i<=$total_pages){
echo "<a href=\"index.php?page=$i\">[$i] </a> ";
}
}
}
else{
for ($i = ($total_pages-5); $i <= ($page+5); $i++) { //show total pages (dont go over (capped))
echo "<a href=\"index.php?page=$i\">[$i] </a> ";
}
}
if($page<$total_pages){
$npage = $page+1;
echo "<a href=\"index.php?page=$npage\">Next»</a>";
}
if($page>1){
$ppage = $page-1;
echo "<a href=\"index.php?page=$ppage\">«Prev</a> ";
}
$capped_pages = $total_pages-4;
if($page==1){
for ($i = $page; $i <= ($page+5); $i++) {
if($i<=$total_pages){
echo "<a href=\"index.php?page=$i\">[$i] </a> ";
}
}
}
else if($page<$capped_pages){
for ($i = $ppage; $i <= ($page+5); $i++) { //previous page added here also ...so if on page 3 it shows pages 23456
if($i<=$total_pages){
echo "<a href=\"index.php?page=$i\">[$i] </a> ";
}
}
}
else{
for ($i = ($total_pages-5); $i <= ($page+5); $i++) { //show total pages (dont go over (capped))
echo "<a href=\"index.php?page=$i\">[$i] </a> ";
}
}
if($page<$total_pages){
$npage = $page+1;
echo "<a href=\"index.php?page=$npage\">Next»</a>";
}
Comment