Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

simple pagination in php

$dbhost = 'localhost';  
$dbuser = 'root';  
$dbpass = '';  
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');  
$dbname = 'test';
$conn = mysqli_connect($dbhost, $username, $password, $dbname) or die("Connection failed: " . mysqli_connect_error());
    /* check connection */
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s
", mysqli_connect_error());
        exit();
    }    
$limit = 2;  
if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; };  
$start_from = ($page-1) * $limit;  
  
$sql = "SELECT * FROM posts ORDER BY title ASC LIMIT $start_from, $limit";  
$rs_result = mysqli_query($conn, $sql);    
};  
Source by www.phpflow.com #
 
PREVIOUS NEXT
Tagged: #simple #pagination #php
ADD COMMENT
Topic
Name
9+9 =