【发布时间】:2015-04-05 18:21:32
【问题描述】:
除了datatable中正常的排序能力外,我想默认以降序(按id从mysql结果排序)显示我的datatable。但是没有任何错误,它一直按升序显示数据表。
以下是我目前所做的: JS:
$('#example').dataTable({
"aaSorting": [[0, "desc"]]
});
和我的服务器端: PHP:
SELECT s . * , c.name AS cls, sec.name AS sect
FROM `student` s
INNER JOIN cls c
ON s.cls = c.id
INNER JOIN sect sec
ON s.sect = sec.id
ORDER BY s.id DESC
HTML:
<table class="table table-striped
table-bordered bootstrap-datatable datatable" id="example">
//table data here
</table>
非常感谢任何建议和帮助。
【问题讨论】:
-
会不会是JS跟SQL倒序了?
-
也许您订购了两次:在您的 SQL 中:DESC,然后在 JS 中:再次 DESC。 DESC*DESC=ASC
标签: php jquery mysql datatable