so i am using this code in my wordpress site

pagination script

works fine in my website but its not working in wordpress, i cant change the permalinks i already tried, it gave me 4040 pages on every page. so that is out of the question

this part is where it creates the links to each new page

for ($i=1; $i<=$total_pages; $i++) {  // print links for all pages
           echo "<a href='page=".$i."'";
           if ($i==$page)  echo " class='curPage'";
           echo ">".$i."</a> "; 
     }; 

so it will become proof?page=12

but if you click on that link in my wordpress it will then go to proof/12/

i have several pages that use links like… page?user=2&game=2 and it does not cut them off in that way and change the url…

i will add full code from that tuorial as well:

 <?php
    if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; };
        $start_from = ($page-1) * $results_per_page;
        $sql = "SELECT * FROM ".$datatable." ORDER BY ID ASC LIMIT $start_from, 
        ".$results_per_page;
        $rs_result = $conn->query($sql);
    ?> 
       <table border="1" cellpadding="4">
       <tr>
          <td bgcolor="#CCCCCC"><strong>ID</strong></td>
          <td bgcolor="#CCCCCC"><strong>Name</strong></td><td bgcolor="#CCCCCC">
           <strong>Phone</strong></td></tr>
     <?php 
         while($row = $rs_result->fetch_assoc()) {
      ?> 
            <tr>
            <td><? echo $row["ID"]; ?></td>
            <td><? echo $row["Name"]; ?></td>
            <td><? echo $row["PhoneNumber"]; ?></td>
            </tr>
   <?php 
    }; 
    ?> 
   </table>



    <?php 
    $sql = "SELECT COUNT(ID) AS total FROM ".$datatable;
    $result = $conn->query($sql);
    $row = $result->fetch_assoc();
    $total_pages = ceil($row["total"] / $results_per_page);  

       for ($i=1; $i<=$total_pages; $i++) {  // print links for all pages
            echo "<a href='index.php?page=".$i."'";
            if ($i==$page)  echo " class='curPage'";
            echo ">".$i."</a> "; 
        }; 
       ?>

i have tried hardocoding the full url as well and same result it redirects to proof/12/ and not proof?page=12

i think its here in this part of the code:

   if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; };
   $start_from = ($page-1) * $results_per_page;

Read more here: php pagination issue when used in wordpress


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: