How to create pagination automatically using php/mysql?

I want to know how can i create pagination directly from database using php/mysql am try to create it but am stack right now because it only show ten rows but it doesn’t break any page, here are my pages

<?php include 'header.php';?>
<?php include ('../control/function.php'); ?>
    <div class="content-wrapper">
         <div class="container">
        <div class="row pad-botm">
            <div class="col-md-12">
                <h4 class="header-line">Background For Sold Items</h4>

             <div class="row " style="padding-bottom:40px;">
           <div class="container-fluid">
              <th>SOLD ITEMS</th>
              <?php view_sold(); ?>

                   <!-- COMMENT SECTION - ONE END-->
   <?php include 'footer.php';?>


function view_sold(){
  include ('connect.php');
  $select_admin_details="select * from new LIMIT 0,10";

  while ($row_data=mysql_fetch_array($run_admin_details)) {

    echo "<tr>

Your query retrieves the first ten rows from your table. What you need to do now is to put a link for the “next page” which calls the same function, but recovers the next ten rows. One way would be to pass the page number, or the starting row, into the view_sold() function and have your link or Ajax call provide it. Once you have that, obviously you can add links to previous page, first page, and so on.

You also need to look at moving from the old-style (and no longer part of the language) mysql calls and use something like mysqli or, my preference, PDO.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.