Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6741517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:44:03+00:00 2026-05-26T11:44:03+00:00

I would like to modify the script below so that there are no pagination

  • 0

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! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:44:04+00:00Added an answer on May 26, 2026 at 11:44 am

    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).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The script below illustrates a capability of set and frozenset that I would like
We have a customer that would like to modify application user messages that we
I have code, similar to the following, that I would like to modify: Sub
I would like to know how to modify the below code to strip =20
I would like modify HTML like I am <b>Sadi, novice</b> programmer. to I am
I would like to modify a Spotlight metadata attribute of a file within my
I would like to modify the string in a .h file with NAnt before
I have a String which I would like to modify in some way. For
I'm absolutely new to JavaScript and would like to modify a textarea of a
I'm using HighLine to write my console application and I would like to modify

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.