PHP - MySQL query with Pagination

后端 未结 3 1458
北荒
北荒 2020-12-20 00:10

How would I go about making a pagination script for this MySQL & PHP query.

if (isset($_GET[\'c\'])) {
$c = $_GET[\'c\'];
}

$query = mysql_query(\"SELEC         


        
3条回答
  •  隐瞒了意图╮
    2020-12-20 00:43

        Pagiantion, it is working simple and easy 
           query($sql); 
            $row = mysqli_fetch_row($rs_result);  
            $total_records = $row[0]; 
            echo $total_records;
            $previous   = 1;
            $total_pages = ceil($total_records / $limit); 
            $next  = $_GET["page"] + 1;
            $previous  = $_GET["page"] - 1;
            $pagLink = ""; 
            if($previous ==0)
            {
            $prev  = "Previous";
            }
            else
            {
              $prev  = "Previous";   
            };
            echo $prev;
    
            "";
          ?>
    

    Get all data from database.

                $limit = 1;  
                if (isset($_GET["page"])) 
                {
                    $page  = $_GET["page"];
                }
                else 
                {
                 $page=1; 
                }  
                $start_from = ($page-1) * $limit;     
                $sql = "SELECT * FROM contact_info ORDER BY id desc LIMIT $start_from , $limit";
    

提交回复
热议问题