日期表排序PHP页面- MySql


Date Table Sort PHP Page--- MySql

大家好!我想把我的表格按日期排序,但是我不能。

我的代码

<table class="table table-striped table-bordered bootstrap-datatable datatable responsive">
<thead>
<tr>
<th>Name</th>
<th>Action</th>
<th>Date and Time</th>
</tr>
</thead>
<tbody>
<?php
$result= mysql_query("select * from history order by history_id DESC ") or die (mysql_error());
while ($row= mysql_fetch_array ($result) ){
$id=$row['history_id'];
?>
<tr>
<td><?php echo $row['data']; ?></td>
<td><span class="label-primary label label-default"><?php echo $row['action']; ?></span></td>
<td><span class="label-success label label-default"><?php echo date("M d, Y H:i:s",strtotime($row['date'])); ?></span></td>
</tr>
<?php } ?>
</tbody>
</table>

您忘记粘贴代码了,所以我希望这是您想要的:

按日期排序:

ALTER TABLE table1
ORDER BY table1.Date DESC,

按日期排序:

ALTER TABLE table1
ORDER BY table1.Date ASC