Refresh Server Side Datatable After every n Seconds eg. 30 Seconds (PHP and Mysql)
Refresh Server Side Datatable After every n Seconds eg. 30 Seconds (PHP and Mysql)
etsm
Posts: 3Questions: 0Answers: 0
Hi to all members!!!
Forgive me, my English is not good.
I'm a newbie in PHP, MySQL, Ajax and Datatables as well.
I have been asked to by my boss to design a Flight Information Display System (FIDS) which will show Departure and Arrival of airlines in a real time basis.
I have come across Datatables recently and I think it can serve the purpose.
I want the datatable to refresh after every 30minutes with the latest data from Mysql Datatabase.
I have started the project from code obtained from this url
http://www.sharemycode.com/item/view/95/jquery-datatables-plugin-example-with-php-mysql
Comment, tutorial or any helpful material will be aprreciated.
Here are my script.
<?php
$con = mysql_connect("localhost", "root", "");
if (!$con) {
die("Error: " . mysql_error());
}
mysql_select_db("FIDS", $con);
$result = mysql_query("SELECT * FROM arrival");
?>
<!DOCTYPE html>
DataTables
@import "media/css/demo_table_jui.css";
@import "media/themes/smoothness/jquery-ui-1.8.4.custom.css";
*{
font-family: arial;
}
var myApp = myApp || {};
$(document).ready(function(){
myApp.oTable = $('#datatables').dataTable({
"sPaginationType":"full_numbers",
"aaSorting":[[2, "desc"]],
"bJQueryUI":true,
"fnServerData": function ( sSource, aoData, fnCallback ) {
//Disable cache
$.ajax( {
dataType: 'json',
type: "GET",
cache: false,
url: sSource,
data: aoData,
success: fnCallback
} )
}
});
});
myApp.polling = setInterval('myApp.oTable.fnDraw(false)', 5000);
Airline
Flightno
Scheduled Time
Origin City
Status
Logo
<?php
while ($row = mysql_fetch_array($result)) {
?>
<?=$row['airline']?>
<?=$row['flightno']?>
<?=$row['sched']?>
<?=$row['origin']?>
<?=$row['status']?>
<?=""?>
<?php
}
?>
Forgive me, my English is not good.
I'm a newbie in PHP, MySQL, Ajax and Datatables as well.
I have been asked to by my boss to design a Flight Information Display System (FIDS) which will show Departure and Arrival of airlines in a real time basis.
I have come across Datatables recently and I think it can serve the purpose.
I want the datatable to refresh after every 30minutes with the latest data from Mysql Datatabase.
I have started the project from code obtained from this url
http://www.sharemycode.com/item/view/95/jquery-datatables-plugin-example-with-php-mysql
Comment, tutorial or any helpful material will be aprreciated.
Here are my script.
<?php
$con = mysql_connect("localhost", "root", "");
if (!$con) {
die("Error: " . mysql_error());
}
mysql_select_db("FIDS", $con);
$result = mysql_query("SELECT * FROM arrival");
?>
<!DOCTYPE html>
DataTables
@import "media/css/demo_table_jui.css";
@import "media/themes/smoothness/jquery-ui-1.8.4.custom.css";
*{
font-family: arial;
}
var myApp = myApp || {};
$(document).ready(function(){
myApp.oTable = $('#datatables').dataTable({
"sPaginationType":"full_numbers",
"aaSorting":[[2, "desc"]],
"bJQueryUI":true,
"fnServerData": function ( sSource, aoData, fnCallback ) {
//Disable cache
$.ajax( {
dataType: 'json',
type: "GET",
cache: false,
url: sSource,
data: aoData,
success: fnCallback
} )
}
});
});
myApp.polling = setInterval('myApp.oTable.fnDraw(false)', 5000);
Airline
Flightno
Scheduled Time
Origin City
Status
Logo
<?php
while ($row = mysql_fetch_array($result)) {
?>
<?=$row['airline']?>
<?=$row['flightno']?>
<?=$row['sched']?>
<?=$row['origin']?>
<?=$row['status']?>
<?=""?>
<?php
}
?>
This discussion has been closed.