Fill DataTable ServerSided - Solved
Fill DataTable ServerSided - Solved
Hi,
i have a Problem to fill the DataTable from MySQL with PHP. I have read the example and used the code snippet. But my the DataTables PlugIn only shows "Processing...".
Can anyone help me? Where is my failure?
[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
$(document).ready(function(){
$('#tsttbl').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "tableContent.php"
} );
} );
Test
Alpha
Numeric
[/code]
[code]
<?php
/* MySQL connection */
$gaSql['user'] = "root";
$gaSql['password'] = "blubb";
$gaSql['db'] = "tbltest";
$gaSql['server'] = "localhost";
$gaSql['type'] = "mysql";
$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'] ) )
{
$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
[/code]
[Edit]
Problem Solved. I have forgotton an ']' so the JSON was wrong.
i have a Problem to fill the DataTable from MySQL with PHP. I have read the example and used the code snippet. But my the DataTables PlugIn only shows "Processing...".
Can anyone help me? Where is my failure?
[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
$(document).ready(function(){
$('#tsttbl').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "tableContent.php"
} );
} );
Test
Alpha
Numeric
[/code]
[code]
<?php
/* MySQL connection */
$gaSql['user'] = "root";
$gaSql['password'] = "blubb";
$gaSql['db'] = "tbltest";
$gaSql['server'] = "localhost";
$gaSql['type'] = "mysql";
$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'] ) )
{
$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
[/code]
[Edit]
Problem Solved. I have forgotton an ']' so the JSON was wrong.
This discussion has been closed.