bserverside=true pagination is not working

bserverside=true pagination is not working

k333hsk333hs Posts: 1Questions: 1Answers: 0
edited March 2016 in Free community support

I just get the long list of table items without pagination. I probably miss something in the PHP script, just don't know what....
Please help.

***************************** javascript ****************************
$('#example1').DataTable({

    "bInfo": true,
    "aLengthMenu": [ 10, 25, 50, 100, 1000 ],
    //"aoColumnDefs": [{ 'bSortable': true, 'aTargets': [ 2 ] }],
    "aaSorting": [[0,'asc']],
    'bAutoWidth': false, 
    'aoColumns' : [
        { 'sWidth': '6%' },
        { 'sWidth': '40%' },
        { 'sWidth': '15%' },
        { 'sWidth': '13%' },
        { 'sWidth': '12%' },
        { 'sWidth': '12%' }
    ],
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "/nature/stat_headq_daily2.php",

});

});

*************************** PHP ***********************************

header ( "Access-Control-Allow-Origin: *" );
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-type: text/html; charset=UTF-8");
header("Access-Control-Allow-Methods = GET, POST, OPTIONS, DELETE");
header("Access-Control-Allow-Headers = DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type, Accept-Language, Origin, Accept-Encoding");

define("ROOT", TRUE); // 아래 4개 페이지를 따로 부를 수 없게
define("PATH", $_SERVER[DOCUMENT_ROOT]);

session_start(); // 세션 스타트

include_once(PATH."/images/connection/Connection.php"); // 디비 관련
include_once(PATH."/images/connection/Function.php"); // 펀션 관련
include_once(PATH."/images/connection/Variable.php"); // 변수 관련
include_once(PATH."/images/connection/Levelcheck.php"); // 인증 관련

// 브랜드별 %
$TotalAll = mysql_fetch_array(mysql_query("select sum(cj*su) as TAll from na_order_detail WHERE s4 != '20'"));
$Brsql = mysql_query("SELECT B.br as Brand, SUM( A.cj * A.su ) as Btotal FROM na_order_detail A LEFT JOIN na_store B ON A.id = B.id WHERE A.s4 != '20' GROUP BY B.br");
while($Brrow = mysql_fetch_array($Brsql)){

if($Brrow[Brand] == 45){
    $BPercent45 = round(($Brrow[Btotal]/$TotalAll[TAll])*100);
}else if($Brrow[Brand] == 48){
    $BPercent48 = round(($Brrow[Btotal]/$TotalAll[TAll])*100);
}else if($Brrow[Brand] == 49){
    $BPercent49 = round(($Brrow[Btotal]/$TotalAll[TAll])*100);
}else if($Brrow[Brand] == 50){
    $BPercent50 = round(($Brrow[Btotal]/$TotalAll[TAll])*100);
}else if($Brrow[Brand] == 51){
    $BPercent51 = round(($Brrow[Btotal]/$TotalAll[TAll])*100);
}else if($Brrow[Brand] == 55){
    $BPercent55 = round(($Brrow[Btotal]/$TotalAll[TAll])*100);
}else if($Brrow[Brand] == 57){
    $BPercent57 = round(($Brrow[Btotal]/$TotalAll[TAll])*100);
}else if($Brrow[Brand] == 133){
    $BPercent133 = round(($Brrow[Btotal]/$TotalAll[TAll])*100);
}

}

$sql1 = "SELECT id, SUM(cjsu), SUM(su) FROM na_order_detail WHERE s4 != '20' GROUP BY id ORDER BY SUM(cjsu) desc";

$result1 = mysql_query($sql1);

$total = mysql_num_rows($result1);
$total1= 1;

if($total==0){

$data['state'] = "err";
$data['msg'] = "데이터가 존재하지 않습니다."; 
echo json_encode($data);

}else{

while($row1=mysql_fetch_array($result1)){

    $Cna=mysql_fetch_array(mysql_query("select * from na_store where id='$row1[id]'"));
    $Cna[cna]=iconv("EUC-KR","UTF-8","$Cna[cna]"); 

    // 브랜드
    if($Cna[br] == 45){
        $BC="background-color:#efc695;";
        $BPercent = $BPercent45;
    }else if($Cna[br] == 48){
        $BC="background-color:#95efca;";
        $BPercent = $BPercent48;
    }else if($Cna[br] == 49){
        $BC="background-color:#ceef95;";
        $BPercent = $BPercent49;
    }else if($Cna[br] == 50){
        $BC="background-color:#95caef;";
        $BPercent = $BPercent50;
    }else if($Cna[br] == 51){
        $BC="background-color:#e595ef;";
        $BPercent = $BPercent51;
    }else if($Cna[br] == 55){
        $BC="background-color:#a095ef;";
        $BPercent = $BPercent55;
    }else if($Cna[br] == 57){
        $BC="background-color:#95eeef;";
        $BPercent = $BPercent57;
    }else if($Cna[br] == 60){
        $BC="background-color:#95efa8;";
        $BPercent = $BPercent60;
    }else if($Cna[br] == 133){
        $BC="background-color:#efe395;";
        $BPercent = $BPercent133;
    }else{
        $BC="";
    }

    $BP = "<div class='progress progress-xs'><div class='progress-bar' style='width: $BPercent%; $BC'></div></div>";    

    $Br = mysql_fetch_array(mysql_query("select cna from na_member where nu='$Cna[br]'"));
    $Br[cna]=iconv("EUC-KR","UTF-8","$Br[cna]");
    $CNA = "<span class='badge' style='$BC'>$Br[cna]</span>";

    $sumcjsu = $row1['SUM(cj*su)'];
    $sumsu = $row1['SUM(su)'];


    $data['aaData'][] = array($total1, $Cna[cna], $sumcjsu, $sumsu, $BP, $CNA); 

    $total1 = $total1 + 1;

}

$data['state'] = "ok";

echo  json_encode($data);

}

@mysql_close();

This discussion has been closed.