How to eliminate this warning "DataTables warning: table id=new_table - Requested unknown"
How to eliminate this warning "DataTables warning: table id=new_table - Requested unknown"
Hi i am using datatable for a project. The retreived records are shown correctly. But everytime the page loads the following warning pop up box is shown "DataTables warning: table id=new_referral_table - Requested unknown parameter '0' for row 0. For more information about this error, please see http://datatables.net/tn/4" and the record count at the bottom shows more than shown entries i.e if 3 records are shown it shows 1 to 4 of 4 entries. Can anyone please help?
<
div class="tab-content navi">
<div id="menu1" class="tab-pane fade in active">
<table id="new_table" class="table table-striped"> <!-- bootstrap table class and striped table class-->
<thead>
<tr> <!-- bootstrap table header class-->
<th> Request ID</th>
<th>Request Date</th> <!-- table headers or column names under which the record values will be displayed-->
<th>C_ID</th>
<th>W_ID</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr>
<?php /* Php While statement which loops and gets the values of all the records*/
while( $row1 = sqlsrv_fetch_array( $stmt1, SQLSRV_FETCH_ASSOC) )
{
echo "<tr>";
echo "<td>".$row1['Req_ID']."</td>";
$string1=$row1["Req_Date"]->format('Y-m-d');
echo "<td>".$string1."</td>";
echo "<td>".$row1['C_ID']."</td>";
echo "<td>".$row1['WID']."</td>";
echo "<td>".$row1['Status']."</td>";
echo "</tr>";
}
?>
</tr>
</tbody>
</table>
<script>
$(document).ready(function(){
$('#new_table').dataTable();
});
</script>
</div>
Answers
Remove the tr and /tr that you have outside of the loop. It is causing your html to not be well formed.