【问题标题】:I want to display all personnel records that the current time is not between to the (column)start_time and end_time(column)我想显示当前时间不在(column)start_time和end_time(column)之间的所有人员记录
【发布时间】:2018-10-09 18:08:49
【问题描述】:

我想显示当前时间不在 (column)start_time 和 end_time(column) 之间的所有人员记录,但如果当前时间在 (column)start_time 和 end_time(column) 之间,则不显示人员姓名。

Sched_time_start = '17:00:00';     
Sched_time_end = '17:35:00';     
$time=date("h:i:s");//this is my current time variable//    

这是我的查询代码:

$qry= "SELECT * from personel as A Left join sched as B on A.Per_ID = B.Sched_Per_ID where '$time' NOT BETWEEN B.Sched_time_start AND B.Sched_time_end";     
$qryres = mysqli_query($connect, $qry);      

所以如果当前时间在“17:00:00”和“17:35:00”之间但当当前时间低于 16:59;00 或 17:36:00 时,我不想显示人员然后在我的选择选项上显示人员姓名

这是我的选择选项代码:

<select>     
<?php while ($rows=mysqli_fetch_array($qryres)) { ?>     
<option><?php echo $rows['Per_fname']; ?></option>     
<?php } ?>     
</select>     

提前致谢

【问题讨论】:

    标签: php mysqli


    【解决方案1】:

    可能有多种情况:

    1. 您正在用较低的h 格式化时间:date("h:i:s");。这将返回 12 小时格式而不是 24 小时格式,所以这应该是:date("H:i:s");。请参阅:PHP: date - Manual 了解更多信息。
    2. 如果您在 MYSQL 表结构中使用 DATETIME 而不是 TIME 类型作为计划开始和结束列,则必须在 $time 变量中包含日、月和年。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-07
      • 1970-01-01
      • 2019-03-17
      • 2021-06-18
      相关资源
      最近更新 更多