ItGo.me Focus on IT Recommend

Home > navigation - PHP Next & Back buttons instead of pagination

navigation - PHP Next & Back buttons instead of pagination

2020腾讯云双十一活动,全年最低!!!(领取3500元代金券),
地址https://cloud.tencent.com/act/cps/redirect?redirect=1074

【阿里云】双十一活动,全年抄底价,限时3天!(老用户也有),
入口地址https://www.aliyun.com/1111/home

I would like to modify the script below so that there are no pagination numbers, just a previous and next button. I would like the previous/next links to show/be grayed out depending on whether the next/previous page exists. For example, if you are on page 1, no previous button would show because page 0 doesn't exist.

The script I'm using at the moment grabs data from a text file - creating dynamic pages - and creates pagination based on that:

(before start of html)

$data=file("brief.txt");
$pages=0;
foreach($data as $temp){
    $x=explode("|",$temp);
    if($x[0]>0){
        $pages=$pages+1;
    }
}
if($_GET['p']){
    $page=$_GET['p'];
}
if($_GET['i']){
    $index=$_GET['i'];
}

if($index == "p"){
    $page=$page-1;
}
if($index == "n"){
    $page=$page+1;
}
if($page < 1){
    $page=1;
}
if($page > $pages){
    $page=$pages;
} 
$line=$data[$page-1];
$fields=explode("|",$line);
?>

(in body section)

 <?php
 $show=6;
 echo "<li><a href='?i=p&p=$page'>&#171; PREV</li></a>";

if($page-($show/2) > 1){
    $temp=$page-$show;
    echo "<li><a href='?p=$temp'>...</li></a>";
}
if($page-($show/2) >= 1 && $page+($show/2) <= $pages){
    $start=$page-($show/2);
    $stop=$page+($show/2);
}
if($page-($show/2) < 1){
    $start=1;
    $stop=$show;
}
if($page+($show/2) > $pages){
    $start=$pages-$show;
    $stop=$pages;
}  
for($i=$start; $i<=$stop; $i++){
    if($page==$i){
        echo "<li class='active'>$i</li></a>";
    }
    else{
        echo "<li><a href='?p=$i'>$i</li></a>";
    }
}
if($page+($show/2) < $pages){
    $temp=$page+$show;
    echo "<li><a href='?p=$temp'>...</li></a>";
}
echo "<li><a href='?i=n&p=$page'>NEXT &#187;</li></a>";
?>

I've gotten just the next and previous buttons to show and work from simply changing the script to this:

<?php
echo "<li><a href='?i=p&p=$page'>&#171; PREV</li></a>";
echo "<li><a href='?i=n&p=$page'>NEXT &#187;</li></a>";
?>

But I don't know where to go from there. Any help would be awesome! :)

Recommend:php - Load more instead of going to next page using pagination/API

the Instagram API limits 35 images per API call I figured out I either had to use AJAX (which I am very poor at) or a mixture of PHP and AJAX. I decided on the latter because I didn't want my access token and user ID made available in the c

answer 1 >>---Accepted---Accepted---Accepted---

For one thing, the nesting of the tags is wrong - </a> should come before </li>. Secondly, the code isn't very elegant - it could be much shorter.

But to answer your question about disabling the links, you could just use

<?php
if($page == 1) echo "<li>echo &#171; PREV</li>" else echo "<li><a href='?i=p&p=$page'>&#171; PREV</a></li>";
if($page == $pages) echo "<li>echo NEXT &#187;" else echo "<li><a href='?i=n&p=$page'>NEXT &#187;</a></li>";
?>

(your total number of pages can be found in $pages).

Recommend:php - How to add previous/next buttons instead of >/< signs in pagination area of category page in opencart

page in the pagination area. I believe this would ease the browsing through pages for customers of all ages. In the template file for category page I only get "echo $pagination;" and when I went to controller file for category page it did n

------splitte line----------------------------