DataTables Ajax + php +mysql
DataTables Ajax + php +mysql
pipechaves
Posts: 5Questions: 0Answers: 0
Hi Guys
Im really really new on DATATABLES
Im trying to pull out some information from mySQLDB in order to use Datatables, without success.........
I tried to follow the example that shows a biiiiiiiiiiiiig script at http://datatables.net/examples/data_sources/server_side.html
but I wasnt able to get any result data.
So for example got a DB students with score and name. <--my php should do the query and
-------------
so to get the json should it be on the php side?
-------------
mysql lets say its select * from students;<--does work returns results
$row = array();
while ( $aRow = mysqli_fetch_array( $rResult ) )
{
$row[] = $aRow["name"];
$row[]=$aRow["score"];
}
$output['aaData'][] = $row;
echo json_encode($output);
-------------------------------------
-------------------------------------
on my html on the area I have
$(document).ready(function(){
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "myphp.php"
} );
{);
and in the Body I got
What Im I doing wrong ??
Im really really new on DATATABLES
Im trying to pull out some information from mySQLDB in order to use Datatables, without success.........
I tried to follow the example that shows a biiiiiiiiiiiiig script at http://datatables.net/examples/data_sources/server_side.html
but I wasnt able to get any result data.
So for example got a DB students with score and name. <--my php should do the query and
-------------
so to get the json should it be on the php side?
-------------
mysql lets say its select * from students;<--does work returns results
$row = array();
while ( $aRow = mysqli_fetch_array( $rResult ) )
{
$row[] = $aRow["name"];
$row[]=$aRow["score"];
}
$output['aaData'][] = $row;
echo json_encode($output);
-------------------------------------
-------------------------------------
on my html on the area I have
$(document).ready(function(){
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "myphp.php"
} );
{);
and in the Body I got
What Im I doing wrong ??
This discussion has been closed.
Replies
Beyond that - please link to a test case as noted in the forum rules.
Allan
Is that just a typo in here, or is it in your actual script?
That isnt my actual script its like an example much like alike
Allan thanks for the tip, sorry I cant link a test case since its on mypc using wamp.
So i wont be needeing the server side processing.
Still fighting here and reading.
first the table or the Jquery SHOULD have the colum names
for example
Name
Score
,
With that you can have your script
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": false,
"sAjaxSource": "your.php"
} );
} );
so far i think thats how it works :)