douzhu1188 2016-11-04 09:38
浏览 51

日期表排序PHP页面 - MySql

Hi Everyone, I would like to sort my table by date but I couldn't sort it. Hope you guys can help me.

Here's my code

<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>
  • 写回答

1条回答 默认 最新

  • dpjj4763 2016-11-04 09:48
    关注

    You forgot to paste the code, and so I hope this is what you wanted:

    Sort table by date, descendingly:

    ALTER TABLE table1
    ORDER BY table1.Date DESC,
    

    Sort table by date, ascendingly:

    ALTER TABLE table1
    ORDER BY table1.Date ASC
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?