AngularJS datagrid paging sorting filter using PHP and MySQL

In this Post We Will Explain About is AngularJS datagrid paging sorting filter using PHP and MySQL With Example and Demo.

Welcome on – Examples ,The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to AngularJS datagrid paging, sorting, filter using PHP and MySQL PHP

In this post we will show you Best way to implement Datatable Pagination, Sorting and Search – Server Side PHP-MySQL, hear for How to Angular JS Grid With Paging,Sorting,Filtering with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Table structure for table `students`

  `studenumber` int(11) NOT NULL,
  `studentName` varchar(50) NOT NULL,
  `studLastName` varchar(50) NOT NULL,
  `studFirstName` varchar(50) NOT NULL,
  `studaddressLine1` varchar(50) NOT NULL,
  `addressLine2` varchar(50) DEFAULT NULL,
  `studCity` varchar(50) NOT NULL,
  `studState` varchar(50) DEFAULT NULL,
  `postalCode` varchar(15) DEFAULT NULL,
  `studCountry` varchar(50) NOT NULL,
  `studRepEmpNumber` int(11) DEFAULT NULL,
  `creditLimit` double DEFAULT NULL,
  PRIMARY KEY (`studenumber`),
  KEY `studRepEmpNumber` (`studRepEmpNumber`)


<!DOCTYPE html>
<html ng-app lang =en>
    <meta charset="utf-8">
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <style type="text/css">
    ul>li, a{cursor: pointer;}
    <title>Simple Angularjs Datagrid with searching, sorting and paging using AngularJS Example, PHP, MySQL</title>
<div class="navbar navbar-default" id="navbar">
    <div class="container" id="navbar-container">
    <div class="navbar-header">
        <a href="" class="navbar-brand">
                <i class="fa-fonts fa-fonts-log-out"></i>
                liveSourcecode / AngularJS Demos 
    <div class="navbar-header pull-right" role="navigation">
        <a href="" class="btn btn-sm btn-danger nav-button-margin"> <i class="fa-fonts fa-fonts-book"></i> Tutorial Link</a>
        <a href="" class="btn btn-sm btn-warning nav-button-margin"> <i class="fa-fonts fa-fonts-download"></i> Download Angularjs</a>

<div ng-controller="liveCtrl">
<div class="container">
<p><h4><a href="">Simple Datagrid with searching, sorting and Paginations using AngularJS + simple PHP with MySQL</a></h4></p>
    <div class="row">
        <div class="col-md-2">PageSize:
            <select ng-model="LiveEntryLimit" class="form-control">
        <div class="col-md-3">Filter:
            <input type="text" ng-model="search" ng-change="filter()" placeholder="Filter" class="form-control" />
        <div class="col-md-4">
            <h5>Filtered {{ filtered.length }} of {{ totalItems}} total students</h5>
    <div class="row">
        <div class="col-md-12" ng-show="liveproducts > 0">
            <table class="table table-striped table-bordered">
            <th>Customer Name <a ng-click="data_sort_live('studentName');"><i class="fa-fonts fa-fonts-sort"></i></a></th>
            <th>Address <a ng-click="data_sort_live('studaddressLine1');"><i class="fa-fonts fa-fonts-sort"></i></a></th>
            <th>City <a ng-click="data_sort_live('studCity');"><i class="fa-fonts fa-fonts-sort"></i></a></th>
            <th>State <a ng-click="data_sort_live('studState');"><i class="fa-fonts fa-fonts-sort"></i></a></th>
            <th>Postal Code <a ng-click="data_sort_live('postalCode');"><i class="fa-fonts fa-fonts-sort"></i></a></th>
            <th>Country <a ng-click="data_sort_live('studCountry');"><i class="fa-fonts fa-fonts-sort"></i></a></th>
            <th>Credit Limit <a ng-click="data_sort_live('creditLimit');"><i class="fa-fonts fa-fonts-sort"></i></a></th>
                <tr ng-repeat="data in filtered = (list | filter:search | orderBy : predicate :reverse) | startFrom:(activePage-1)*LiveEntryLimit | limitTo:LiveEntryLimit">
        <div class="col-md-12" ng-show="liveproducts == 0">
            <div class="col-md-12">
                <h4>No students found</h4>
        <div class="col-md-12" ng-show="liveproducts > 0">    
            <div pagination="" page="activePage" on-select-page="setPage(page)" boundary-links="true" total-items="liveproducts" items-per-page="LiveEntryLimit" class="pagination-small" previous-text="«" next-text="»"></div>
<script src="js/angular.min.js"></script>
<script src="js/ui-bootstrap-tpls-0.10.0.min.js"></script>
<script src="app/app.js"></script>         


var app = angular.module('liveApp', ['ui.bootstrap']);

app.filter('startFrom', function() {
    return function(input, start) {
        if(input) {
            start = +start; //parse to int
            return input.slice(start);
        return [];
app.controller('liveCtrl', function ($scope, $http, $timeout) {
        $scope.list = data;
        $scope.activePage = 1; 
        $scope.LiveEntryLimit = 5; 
        $scope.liveproducts = $scope.list.length;   
        $scope.totalItems = $scope.list.length;
    $scope.setPage = function(pageNo) {
        $scope.activePage = pageNo;
    $scope.filter = function() {
        $timeout(function() { 
            $scope.liveproducts = $scope.filtered.length;
        }, 10);
    $scope.data_sort_live = function(predicate) {
        $scope.predicate = predicate;
        $scope.reverse = !$scope.reverse;


$DB_HOST = 'localhost';
$DB_USER = 'root';
$DB_PASS = '[email protected]';
$DB_NAME = 'livedata_grid';
$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);



$query="select distinct c.studentName, c.studaddressLine1, c.studCity, c.studState, c.postalCode, c.studCountry, c.creditLimit from students c order by c.studenumber";
$result = $mysqli->query($query) or die($mysqli->error.__LINE__);

$liveArray = array();
if($result->num_rows > 0) {
	while($row = $result->fetch_assoc()) {
		$liveArray[] = $row;	
$json_response = json_encode($liveArray);

echo $json_response;


READ :  How to get last executed mysql query in laravel 6?

I hope you have Got Pagination, Searching and Sorting of Data Table using AngularJS And how it works.I would Like to have FeadBack From My Blog( readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article( Are Most Always Welcome.