Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82130

Datatables server side not showing data

$
0
0
i have a script server side like this...
$aColumns = array('username', 'level');
        $sIndexColumn = "id";
        $sTable = "users";

<--------bla-bla-bla---------->

        $sQuery = " SELECT SQL_CALC_FOUND_ROWS " . str_replace(" , ", " ", implode(", ", $aColumns)) . "
        FROM   $sTable
        $sWhere
        $sOrder
        $sLimit
    ";
        $rResult = $this->db->query($sQuery);

        /* Data set length after filtering */
        $sQuery = " SELECT FOUND_ROWS() ";
        $rResultFilterTotal = $this->db->query($sQuery);
        $aResultFilterTotal = $rResultFilterTotal->fetch();
        $iFilteredTotal = $aResultFilterTotal[0];
        
        $sQuery2 = $this->db->prepare("SELECT COUNT(*) FROM users");
        $sQuery2->execute();
        if ($row = $sQuery2->fetch(PDO::FETCH_NUM))
            $iTotal = $row[0];

        $output = array(
            "sEcho" => intval(!isset($_GET['sEcho'])),
            "iTotalRecords" => $iTotal,
            "iTotalDisplayRecords" => $iFilteredTotal,
            "aaData" => array()
        );

        while ($aRow = $rResult->fetch()) {
            $row = array();
            for ($i = 0; $i < count($aColumns); $i++) {
                if ($aColumns[$i] == "version") {
                    /* Special output formatting for 'version' column */
                    $row[] = ($aRow[$aColumns[$i]] == "0") ? '-' : $aRow[$aColumns[$i]];
                } else if ($aColumns[$i] != ' ') {
                    /* General output */
                    $row[] = $aRow[$aColumns[$i]];
                }
            }
            $output['aaData'][] = $row;
        }
        print json_encode($output);

and then output code above like this
{"sEcho":1,"iTotalRecords":"2","iTotalDisplayRecords":"2","aaData":[["van","1"],["van","0"]]}


this my jquery
$(document).ready(function() {
  $('#example').dataTable( {
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "http://localhost/my_project/user/tes"
    } );
});

but data not showing..

can help allan..

Viewing all articles
Browse latest Browse all 82130

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>