Server-side processing(New added data from database does not show up)
Server-side processing(New added data from database does not show up)
jauson
Posts: 7Questions: 0Answers: 0
Hi everyone,
Im just a newbie in datatable. i really need your help in solving my quite small problem with you. I have DT on my webpage and im using server side processing, PHP-MySQL but it seems i forgot some function to make my DT auto refresh or reload, because when I successfully add a new data, when i check my phpmyadmin its in there, but when i check my DT it didnt show up the newly added records there. could you please help me? thanks
heres my code. thanks
$(document).ready(function() {
oTable = $('#the_table').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "get_data_from_history_manager.php"
});
/* Re-draw the table - you wouldn't want to do it here, but it's an example :-) */
oTable.fnDraw();
} );
and
/*
* Script: DataTables server-side script for PHP and MySQL
* Copyright: 2010 - Allan Jardine
* License: GPL v2 or BSD (3-point)
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
$aColumns = array( 'id', 'employeeID', 'name', 'department', 'textFromDate', 'textToDate', 'textTotalDays', 'TypeofLeave', 'ApprovedTimeDate', 'Reason' );
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "id";
/* DB table to use */
$sTable = "leaveapproved";
/* Database connection information */
$gaSql['user'] = "xxxxxxxxxx";
$gaSql['password'] = "xxxxxxxxxx";
$gaSql['db'] = "somedatabase";
$gaSql['server'] = "somelocalhost";
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP server-side, there is
* no need to edit below this line
*/
/*
* MySQL connection
*/
$gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
die( 'Could not open connection to server' );
mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
die( 'Could not select database '. $gaSql['db'] );
/*
* Paging
*/
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
mysql_real_escape_string( $_GET['iDisplayLength'] );
}
/*
* Ordering
*/
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i $iFilteredTotal,
"aaData" => array()
);
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i
Im just a newbie in datatable. i really need your help in solving my quite small problem with you. I have DT on my webpage and im using server side processing, PHP-MySQL but it seems i forgot some function to make my DT auto refresh or reload, because when I successfully add a new data, when i check my phpmyadmin its in there, but when i check my DT it didnt show up the newly added records there. could you please help me? thanks
heres my code. thanks
$(document).ready(function() {
oTable = $('#the_table').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "get_data_from_history_manager.php"
});
/* Re-draw the table - you wouldn't want to do it here, but it's an example :-) */
oTable.fnDraw();
} );
and
/*
* Script: DataTables server-side script for PHP and MySQL
* Copyright: 2010 - Allan Jardine
* License: GPL v2 or BSD (3-point)
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
$aColumns = array( 'id', 'employeeID', 'name', 'department', 'textFromDate', 'textToDate', 'textTotalDays', 'TypeofLeave', 'ApprovedTimeDate', 'Reason' );
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "id";
/* DB table to use */
$sTable = "leaveapproved";
/* Database connection information */
$gaSql['user'] = "xxxxxxxxxx";
$gaSql['password'] = "xxxxxxxxxx";
$gaSql['db'] = "somedatabase";
$gaSql['server'] = "somelocalhost";
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP server-side, there is
* no need to edit below this line
*/
/*
* MySQL connection
*/
$gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
die( 'Could not open connection to server' );
mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
die( 'Could not select database '. $gaSql['db'] );
/*
* Paging
*/
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
mysql_real_escape_string( $_GET['iDisplayLength'] );
}
/*
* Ordering
*/
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i $iFilteredTotal,
"aaData" => array()
);
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i
This discussion has been closed.
Replies
Allan
first of all i want to thank you for this wonderful creation. it saves a lot of time.
anyway
that's all i have in my code. I just dont dont what code im using to do the redraw. sorry.