Search
 
SCRIPT & CODE EXAMPLE
 

PHP

html pagination php

	<?php
		$total_pages = ceil($recordsTotal / $length); 
		$pagBtn = "<ul class='pagination'>"; 
		$active_page = $start;
		$show_page_numbers = [];
		$minus_page = $active_page-2;
		$plus_page = $active_page+3;
		if ($minus_page < 1 || $active_page == 1) {
			$minus_page = 1;
		}
		if ($active_page > 3) {
			$pagBtn .= "<li class='page-item' data-page_no='1'>1</li>";
		}
		if (($minus_page - 1) > 1) {
			$pagBtn .= "... ";
		}
		$last_page = '';
		for ($i=$minus_page; $i < $plus_page; $i++) { 
			if ($i < $total_pages) {
				$show_page_numbers[] = $i;
				$pagBtn .= "<li class='page-item ";
				if ($active_page==$i){ 
					$pagBtn .= " active";
				}
				$pagBtn .= "' data-page_no=".$i.">".$i."</li>"; 
				$last_page = $i;
			}
		}
		if (($total_pages - $last_page) > 1) {
			$pagBtn .= "... ";
		}
		if ($total_pages > $last_page) {
			$pagBtn .= "<li class='page-item ";
				if ($active_page==$total_pages){ 
					$pagBtn .= " active";
				}
				$pagBtn .= "' data-page_no=".$total_pages.">".$total_pages."</li>"; 
		}
		echo $pagBtn . "</ul>"; 
	?>
Comment

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);    
};  
Comment

pagination php

if($page > 1)
{        
 echo '<li><a href="index.php?page='.($page - 1).'">Previous</a></li>'; 
}
Comment

PREVIOUS NEXT
Code Example
Php :: carbon check sunday 
Php :: 12 hrs for preg match with single and double digit in php 
Php :: use php-fpm with apache 
Php :: facade pattern php 
Php :: 3. Write a php script function to get the data type and the value of the variable $x = true. 
Php :: db($twoRandomPhotosOfSomePeoples); 
Java :: basic hello world program in java 
Java :: how to change font size in JLabel 
Java :: java get class by string 
Java :: how to read integer input using bufferedreader java 
Java :: import android.support.v4.app.ActivityCompat; 
Java :: priority queue reverse order java 
Java :: how to loop through code 3 times java 
Java :: java get mouse position on screen 
Java :: Cannot resolve class android.support.design.widget.AppBarLayout 
Java :: java remove empty lines from string 
Java :: com.android.builder.dexing.DexArchiveMergerException: 
Java :: Could not find any matches for com.transistorsoft:tsbackgroundfetch:+ as no versions of com.transistorsoft:tsbackgroundfetch are available. 
Java :: android hide keyboard 
Java :: How to implement a Trie data structures in Java? 
Java :: java close jframe 
Java :: how to delete last char in string java 
Java :: collision java 
Java :: showinputdialog joptionpane 
Java :: ova definition 
Java :: get long from date java 
Java :: Xlint:deprecation android studio 
Java :: admost track purchase 
Java :: smaller elements on right hand side leetcode 
Java :: android java format date time 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =