about the server side

about the server side

asaasa Posts: 20Questions: 0Answers: 0
edited October 2009 in General
hi
how are you ? thanx for this greate plugin , i want to do this with jsp server side
,but my problem is that i dont understand php example coz i dont have any php background .. i tried to understand
but there is this three things i didnt get it .. what $sOrder ,$sLimit for ?and why we use them in the query ?!
the last is this code related to json ?!

[code]$sQuery = "
SELECT FOUND_ROWS()
";


$sOutput = '{';
$sOutput .= '"sEcho": '.$_GET['sEcho'].', ';
$sOutput .= '"iTotalRecords": '.$iTotal.', ';
$sOutput .= '"iTotalDisplayRecords": '.$iFilteredTotal.', ';
$sOutput .= '"aaData": [ ';
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$sOutput .= "[";
$sOutput .= '"'.addslashes($aRow['engine']).'",';
$sOutput .= '"'.addslashes($aRow['browser']).'",';
$sOutput .= '"'.addslashes($aRow['platform']).'",';
if ( $aRow['version'] == "0" )
$sOutput .= '"-",';
else
$sOutput .= '"'.addslashes($aRow['version']).'",';
$sOutput .= '"'.addslashes($aRow['grade']).'"';
$sOutput .= "],";
}
$sOutput = substr_replace( $sOutput, "", -1 );
$sOutput .= '] }';

echo $sOutput;
[/code]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi asa,

    You are quite correct - the last code block there (all the $sOutput concatenations) is to do with creating a JSON string to return to the browser. The various other parts are the queries which are required in order to create this JSON. It might be worth reading over this page which gives details about the format that DataTables is expecting: http://datatables.net/usage/server-side

    Regards,
    Allan
  • asaasa Posts: 20Questions: 0Answers: 0
    Hi allan
    thanx for your fast replay ... and so sorry i didnt read the usage i go direct to the examples
    one thing i didnt find what the use of $sLimit value
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi,

    $sLimit is an "internal" variable to the PHP script based upon $_GET['iDisplayStart'] and $_GET['iDisplayLength']. This limits the query to return just the rows for the current page.

    Regards,
    Allan
This discussion has been closed.