DataTables Ajax + php +mysql

DataTables Ajax + php +mysql

pipechavespipechaves Posts: 5Questions: 0Answers: 0
edited February 2014 in DataTables 1.9
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 ??

Replies

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    Firstly - do you actually need server-side processing? Are you working with 50'000+ rows of data? If not, do without server-side processing, it is much simpler since you just return the json data representing the data for the table.

    Beyond that - please link to a test case as noted in the forum rules.

    Allan
  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    [quote]{);[/quote] (end of initialisation script)
    Is that just a typo in here, or is it in your actual script?
  • pipechavespipechaves Posts: 5Questions: 0Answers: 0
    edited February 2014
    Tangerine
    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.
  • pipechavespipechaves Posts: 5Questions: 0Answers: 0
    So here is an update to those having the same issue as I do

    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 :)
  • pipechavespipechaves Posts: 5Questions: 0Answers: 0
    edited February 2014
    Issue solved, thank guys
This discussion has been closed.