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 | |
$image = null; | |
$humidity = '0.56'; | |
$wind = '45'; | |
$city = "galway"; | |
$temperature = 300; | |
/* Get Location IP section | |
localhost ip address not for website | |
$ip = $_SERVER['HTTP_CLIENT_IP'] ? | |
$_SERVER['HTTP_CLIENT_IP'] : ($_SERVER['HTTP_X_FORWARDED_FOR'] ? |
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
include '../DB/configDB.php'; |
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
if (isset($_POST['action']) && !empty($_POST['action'])) { | |
$action = $_POST['action']; | |
switch ($action) { | |
case 'getEMP' : | |
getEMP($DBconnect); | |
break; | |
case 'getProd' : | |
getProducts($DBconnect); | |
break; | |
// ...etc... |
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
function getEMP($DBconnect) | |
{ | |
// storing request (ie, get/post) global array to a variable | |
$requestData = $_REQUEST; | |
$columns = array( | |
// datatable column index => database column name | |
0 => 'employee_name', | |
1 => 'employee_salary', | |
2 => 'employee_age' | |
); |
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 | |
define('DB_SERVER', 'localhost'); | |
define('DB_USERNAME', 'username'); | |
define('DB_PASSWORD', 'passwordForDB'); | |
define('DB_NAME', 'DatabaseName'); | |
$DBconnect = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME); | |
//echo "Connect Successfully. Host info: " . mysqli_get_host_info($DBconnect); | |
if (!$DBconnect) { | |
die("Connection failed: " . mysqli_connect_error()); | |
} |
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
$(document).ready(function () { | |
var dataTable = $('#employee-grid').DataTable({ | |
"responsive": true, | |
"processing": true, | |
"serverSide": true, | |
"ajax": { | |
url: "ajax/response.php", // json datasource | |
data: {action: 'getEMP'}, // Set the POST variable called action to contain getEMP | |
type: 'post', // method , by default get | |
}, |
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="container"> | |
<div class | |
<div class="header"><h1>Server side DataTable demo in Php,Mysql and Ajax </h1></div> | |
<div class="container"> | |
<table id="employee-grid" class="table table-striped table-bordered" style="width:100%"> | |
<thead> | |
<tr> | |
<th>Employee name</th> | |
<th>Salary</th> | |
<th>Age</th> |
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
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> | |
<link href="https://cdn.datatables.net/1.10.16/css/dataTables.bootstrap.min.css" rel="stylesheet"/> | |
<script src="https://code.jquery.com/jquery-3.3.1.min.js" | |
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" | |
crossorigin="anonymous"></script> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> | |
<script type="text/javascript" src="https://cdn.datatables.net/r/dt/dt-1.10.9/datatables.min.js"></script> | |
<script type="text/javascript" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script> | |
<script type="text/javascript" src="https://cdn.datatables.net/1.10.16/js/dataTables.bootstrap.min.js"></script> |
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 | |
define('DB_SERVER', 'localhost'); | |
define('DB_USERNAME', 'username'); | |
define('DB_PASSWORD', 'passwordForDB'); | |
define('DB_NAME', 'DatabaseName'); | |
$DBconnect = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"/> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"/> | |
<meta name="viewport" content="width=device-width, initial-scale=1"/> | |
<meta name="description" content=""/> | |
<meta name="author" content=""/> |
NewerOlder