This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE IF NOT EXISTS `customers` ( | |
`customerNumber` int(11) NOT NULL, | |
`customerName` varchar(50) NOT NULL, | |
`contactLastName` varchar(50) NOT NULL, | |
`contactFirstName` varchar(50) NOT NULL, | |
`addressLine1` varchar(50) NOT NULL, | |
`addressLine2` varchar(50) DEFAULT NULL, | |
`city` varchar(50) NOT NULL, | |
`state` varchar(50) DEFAULT NULL, | |
`postalCode` varchar(15) DEFAULT NULL, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$DB_HOST = '127.0.0.1'; | |
$DB_USER = 'root'; | |
$DB_PASS = ''; | |
$DB_NAME = 'angularcode_grid'; | |
$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include('../includes/config.php'); | |
$query="select distinct c.customerName, c.addressLine1, c.city, c.state, c.postalCode, c.country, c.creditLimit from customers c order by c.customerNumber"; | |
$result = $mysqli->query($query) or die($mysqli->error.__LINE__); | |
$arr = array(); | |
if($result->num_rows > 0) { | |
while($row = $result->fetch_assoc()) { | |
$arr[] = $row; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = angular.module('myApp', ['ui.bootstrap']); | |
app.filter('startFrom', function() { | |
return function(input, start) { | |
if(input) { | |
start = +start; //parse to int | |
return input.slice(start); | |
} | |
return []; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html ng-app="myApp" ng-app lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<link href="css/bootstrap.min.css" rel="stylesheet"> | |
<style type="text/css"> | |
ul>li, a{cursor: pointer;} | |
</style> | |
<title>Simple Datagrid with search, sort and paging using AngularJS, PHP, MySQL</title> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_FILENAME} !-s | |
RewriteRule ^(.*)$ api.php?x=$1 [QSA,NC,L] | |
RewriteCond %{REQUEST_FILENAME} -d | |
RewriteRule ^(.*)$ api.php [QSA,NC,L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = angular.module('myApp', ['ngRoute']); | |
app.factory("services", ['$http', function($http) { | |
var serviceBase = 'services/' | |
var obj = {}; | |
obj.getCustomers = function(){ | |
return $http.get(serviceBase + 'customers'); | |
} | |
obj.getCustomer = function(customerID){ | |
return $http.get(serviceBase + 'customer?id=' + customerID); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style type="text/css"> | |
.form-horizontal input.ng-invalid.ng-dirty { | |
border-color: #FA787E; | |
} | |
.form-horizontal input.ng-valid.ng-dirty { | |
border-color: #78FA89; | |
} | |
</style> | |
<div class="view"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="row"> | |
<div class="col-md-12" ng-show="customers.length > 0"> | |
<nav class= "navbar navbar-default" role= "navigation" > | |
<div class= "navbar-header" > | |
<a class="btn btn-lg btn-success" href="#/edit-customer/0"><i class="glyphicon glyphicon-plus"></i> Add new Customer</a> | |
</div> | |
</nav> | |
<table class="table table-striped table-bordered"> | |
<thead> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class REST { | |
public $_allow = array(); | |
public $_content_type = "application/json"; | |
public $_request = array(); | |
private $_method = ""; | |
private $_code = 200; | |