dongyi6195 2014-02-17 02:23
浏览 42
已采纳

数据库仍然显示较旧的条目,当我没有设置

I'm using a MySQL database, accessing it through PHP, and I want it to not show older entries then today's date. I had a heck of a time getting it to order them. I had it working before, now it's not. I have them ordered by ASC, by date, fine, but it's still showing older entries. I know my PHP is outdated, but any method will work for me. Here's my code.

Sorry if I come off as a complete ditz.. I come here if I don't know, and I'm relatively new to this, and always get hung up on dates.

So far it's been suggested to: Change the name of the "date" column. "date" is stored as datetime, not a string, so to change that to int

// this is where its set to show today and future dated entries
$sql = "SELECT * FROM $db WHERE date >= '$today' ORDER BY date ASC" or die(mysql_error());

$getit = mysql_query ( $sql, $conn );

print "<br><b><font size=4>Appointments Coming Up</b></font>";
while($row = mysql_fetch_array($getit, MYSQL_ASSOC))
{
print "<br>";


$row[date] = date("D-M-d-Y", strtotime($row[date]));
print "<br><font size=3><b>{$row['doctor']} at {$row['time']} {$row['ampm']} on      $row[date]</font>";

}

Solved All I did was change the date column in the database to "dateappt" and it worked. Thanks for the help everyone.

  • 写回答

3条回答 默认 最新

  • dtvq4978 2014-02-17 02:44
    关注

    Firstly "Date" is a reserved word (case sensitivity is dependant) so you should change the name of this column.

    MySQL only uses 'YYYY-MM-DD' format for dates so your formats must match this (your $today).

    http://dev.mysql.com/doc/refman/5.0/en/using-date.html

    It may be better for you to use timestamps.

    There are other ways of manipulating dates though: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 yolov8边框坐标
  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真