Intro: I am doing a server-side datatable.net Jquery plug-in using json, ajax, and ssp.class.php. I have it working but attempting to make buttons that can edit and delete. I am able to do this without the plug-in (but for some reason am stumped currently).
Code:
$(document).ready(function() {
$('#example').DataTable( {
// "pagingType": "scrolling",
"processing": true,
"serverSide": true,
"ajax": {
"url": "server.php",
"type": "POST"
},
});
});
</script>
<body>
<table id="example" class="display" style="width:100%" class="table table-striped table-bordered table-hover table-condensed">
<thead class="thead-inverse">
<tr>
<th><a class="column_sort" id="id" href="?order=id&sort=<?php echo $sort; ?>">
ID
</th>
<th><a class="column_sort" id="first_name" data-order="<?php echo $sort;?>" href="?order=first_name&sort=<?php echo $sort; ?>">First Name </a>
</th>
<th><a class="column_sort" id="last_name" href="?order=last_name&sort=<?php echo $sort; ?>">Last Name
</a>
</th>
<th><a class="column_sort" id="position" href="?order=position&sort=<?php echo $sort; ?>">Position
</a>
</th>
<th class="hidden-xs"><a class="column_sort" id="date" href="?order=date&sort=<?php echo $sort; ?>">Date </a>
</th>
<th class="hidden-xs"><a class="column_sort" id="updated" href="?order=updated&sort=<?php echo $sort; ?>">Updated
</a> </th>
<th>Action</th>
</thead> </tr>
<tbody>
</tbody>
</table>
</div>
<?php
$orderby="";
$sort="";
$sort = isset($_GET['sort']) ? $_GET['sort'] : 'ASC';
$sort = ($sort == 'ASC') ? 'DESC': 'ASC';
$order = array("first_name","last_name", "date", "position", "updated");
$key = array_search($sort, $order);
$orderby = $order[$key];
$records = mysqli_query($con, "SELECT * FROM employees ORDER BY $orderby $sort");
$data=array();
while ($row = mysqli_fetch_array($records, MYSQLI_ASSOC)) {
$row['delete_button']='<button type="button" class="btn btn-warning">Delete</button>';
$data[]=$row;
}
$requestData= $_REQUEST;
$count=mysqli_query($con, "SELECT * FROM employees");
$totalData= $count->num_rows;
$totalFiltered=$totalData;
$json_data = array(
"draw" => intval(isset($_GET['draw'])),
"recordsTotal" => intval( $totalData ),
"recordsFiltered" => intval( $totalFiltered ),
"data" => $data //How To Retrieve This Data
);
echo json_encode($json_data);
?>
Error: DataTables warning: table id=example - Requested unknown parameter '6' for row 0, column 6. For more information about this error, please see http://datatables.net/tn/4
There is a similiar topic already out and no one seems to have any leads. Any help would be appreciated. Thanks in advance.