I make php form for sql data view. problem is i want view latest data in top and old data last. can some help me?? Here is my php form view code. all details here for get data from sql. and its work fine, but in need view latest to old.
<table cellpadding="0" cellspacing="0" border="0" class="datatable table table-striped table-bordered">
<thead>
<tr>
<th>S.No</th>
<th class="wraper-title">Notice Title</th>
<th>Publish Date</th>
<th>Type</th>
<th>View</th>
<th>Delete</th>
<th>Download</th>
</tr>
</thead>
<tbody>
<?php
while($r = mysqli_fetch_assoc($result)){
?>
<tr>
<th scope="row"><?php echo $r['id'] ?></th>
<td class="wraper-title"><?php echo $r['name'] ?></td>
<td><?php echo $r['date'] ?></td>
<td><?php echo $r['type'] ?></td>
<td>
<a type="button" class="btn btn-success" href="<?php echo $r['location'] ?>">View</a>
</td>
<td>
<a type="button" class="btn btn-danger delete" title="Delete this notice" href="#" onclick='DeleteFile(<?php echo $r['id'] ?>)'><i class="glyphicon glyphicon-trash"></i></a>
</td>
<td>
<a type="button" class="btn btn-primary download" href="<?php echo $r['location'] ?>" title="Download <?php echo $r['name'] ?>" download="<?php echo $r['name'] ?>" {%=file.thumbnailUrl?'data-gallery':''%}><i class="glyphicon glyphicon-download"></i></a>
</td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<tr>
<th>S.No</th>
<th class="wraper-title">Notice Title</th>
<th>Publish Date</th>
<th>Type</th>
<th>View</th>
<th>Delete</th>
<th>Download</th>
</tr>
</tfoot>
</table>
please help me
You can try this feature. This will order your first and second column in ascending order.
where 0 and 1 are index of your columns
$('#table_id').dataTable( {
"order": [[ 0, 'asc' ], [ 1, 'asc' ]]
});