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

后端 未结 6 731
北恋
北恋 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:30

    Link is here for demo, click here to experience the result

    Here is the code working for me, just change your db name, username and password and get pagination done. You can change $rec_limit value to your desired no. of records per page.

    ";
      $i = 0;
      while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {
    
       if ($i == 0) {
            $i++;
            echo "";
            foreach ($row as $key => $value) {
              echo "" . $key . "";
            }
            echo "";
            }
            echo "";
            foreach ($row as $value) {
            echo "" . $value . "";
           }
          echo "";
    
         }
        echo "";
    
    if( $page > 0 ) {
    $last = $page - 2;
    echo "Last 5 Records | ";
    echo "Next 5 Records";
    
    }else if( $page == 0 ) {
    $page = $page + 0;
    echo "Next 5 Records";
    
    }else if( $left_rec < $rec_limit ) {
    
    $last = $page - 2;
    echo "Last 5 Records";
    
    }
    
         mysql_close($conn);
    php?>
    

提交回复
热议问题