How to display only 5 records per page from my mysql database table through pagination?

后端 未结 6 780
北恋
北恋 2021-01-06 11:51

I want to display five record per page through pagination (mysql,php,html,css) until all the records are displayed, navigation to pages must be like,

6条回答
  •  执念已碎
    2021-01-06 12:38

    IF your are using mysqli the code is below

     $conn=mysqli_connect("localhost","root","","ui");
    
    
     $start=0;
      $limit=5;
    
      $t=mysqli_query($conn,"select * from form_table");
      $total=mysqli_num_rows($t);
    
    
    
       if(isset($_GET['id']))
       {
            $id=$_GET['id'] ; 
                            $start=($id-1)*$limit;
    
                              }
                else
                {
            $id=1;
       }
       $page=ceil($total/$limit);
    
       $query=mysqli_query($conn,"select * from form_table limit                                        $start, $limit");
     ?>
     
     
     
     
     
     
         
                  
     
    
    

    Table

    Id Name Gender Hobbies Course

提交回复
热议问题