DataTables Pagination Server-side Processing using PHP and MySQL

DataTables Pagination Server-side Processing using PHP and MySQL

In this Post We Will Explain About is DataTables Pagination Server-side Processing using PHP and MySQL With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to DataTables Server-side Processing using PHP with MySQLExample

In this post we will show you Best way to implement DataTable Pagination using PHP & MySQL Example, hear for create jQuery Datatable pagination using PHP and MySQLwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Read Also:  How to implement pagination with server side get api in Datatables?

Project Structure

index.php
config.php
data_allpage.php
pagefunc.js

Mysql Table : create table structure

CREATE TABLE `students` (
`id` int(11) NOT NULL COMMENT 'primary key',
`stud_name` varchar(255) NOT NULL COMMENT 'students name',
`stud_fees` double NOT NULL COMMENT 'students salary',
`stud_age` int(11) NOT NULL COMMENT 'students age'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

config.php

<?php
$yoursname = "localhost";
$username = "root";
$password = "[email protected]";
$dbname = "pakainfo";
$conn = mysqli_connect($yoursname, $username, $password, $dbname);
?>

jquery library files

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="https:////cdn.datatables.net/1.10.12/css/jquery.dataTables.css">
<script src="https:////cdn.datatables.net/1.10.12/js/jquery.dataTables.js"></script>

index.php

<div class="container">
<h2>Simple jQuery DataTable server side Pagination using PHP & MySQL Examples</h2>
<div class="row">
<table id="livedatatable" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th>stud_id</th>
<th>Name</th>
<th>fees</th>
</tr>
</thead>
</table>
</div>
<div style="margin:50px 0px 0px 0px;">
<a class="btn btn-default read-more" style="background:#3399ff;color:white" href="http://www.Pakainfo.com/tutorial" title="free Download All Example">Back to Tutorial</a>
</div>
</div>

pagefunc.js

jQuery( document ).ready(function() {
var table = jQuery('#livedatatable').dataTable({
"bProcessing": true,
"sAjaxSource": "data_allpage.php",
"bPaginate":true,
"sPaginationType":"full_numbers",
"iDisplayLength": 10,
"bLengthChange":false,
"bFilter": false,
"aoColumns": [
{ mData: 'stud_id' } ,
{ mData: 'Name' },
{ mData: 'fees' }
]
});
});

data_allpage.php

<?php
include_once("config.php");
$sql = "SELECT id as stud_id,stud_name as Name,stud_fees as fees FROM students LIMIT 20";
$dataresults = mysqli_query($conn, $sql) or die("simple your database error:". mysqli_error($conn));
$studarray = array();
while( $datarows = mysqli_fetch_assoc($dataresults) ) {
$studarray[] = $datarows;
}
$results = array(
"sEcho" => 1,
"iTotalRecords" => count($studarray),
"iTotalDisplayRecords" => count($studarray),
"aaData"=>$studarray);
echo json_encode($results);
exit;
?>

Example

I hope you have Got What is DataTables Server-side Processing using PHP with MySQL And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.