When I try to retrieve data from my database to the table, I get the below error:
DataTables warning (table id = 'myTable'): Requested unknown parameter '0' from the data source for row 1
Below is the js that I used
<script>
$(document).ready(function() {
$('#myTable').dataTable();
});
</script>
Below is my table
<table id="myTable" class="table table-striped table-bordered table-hover table-condensed">
<thead>
<tr>
<th>Name</th>
<th>Date</th>
<th>Options</th>
</tr>
</thead>
<tbody id="myTableOK">
<?php echo $tableQuery ?>
</tbody>
</table>
php Code
function tableQuery($linkDB){
$out = '';
$query = $linkDB -> query("SELECT id,name,date
FROM tbl_mytable ORDER BY name ASC");
if($query -> num_rows != 0){
while($listOK = $query -> fetch_assoc())
{
$out .= '
<tr>
<td>'.$listOK ['name'].'</td>
<td>'.$listOK ['date'].'</td>
<td class="centerTXT"><a data-action="edit" class="btn btn-xs" href="'.$listOK ['id'].'">Edit</a> <a data-accion="delete" class="btn btn-xs" href="'.$listOK ['id'].'">delete</a></td>
<tr>
';
}
}
else{
$out = '
<tr id="noData">
<td colspan="5" class="centerTXT">DATABASE WITHOUT DATA</td>
</tr>
';
}
return $out;
}
I'm using DataTables.
Can someone tell me why am I getting that error and how to retrieve the data to the table?
It is because I'm using PHP to dynamically show the data records of the database?
Thank you.