0

我有一个查询显示用户以年-月-日开始时间(00:00:00)结束时间(00:00:00)格式进行的约会,现在我想将整个格式与当前格式进行比较时间,如果它等于或更高不显示预约,因为用户可以选择取消预约,如果预约时间已经过去,我想对他隐藏取消预约选项......这是我的查询和 html回声...

$result = mysql_query("SELECT id,date,start,end FROM jos_jxtc_appbook_appointments WHERE userident='$idusera'");
while($row = mysql_fetch_assoc($result))
{
echo '<div class="record" id="record-',$row['id'],'">
    <a href="?delete=',$row['id'],'" class="delete">Delete</a>
    <strong>',$row['date'], $row['start'], $row['end'],'</strong>
  </div>';
}
4

2 回答 2

0

除了不使用mysql_函数,只使用时间函数进行比较:

SELECT ... FROM ... WHERE timeColumn > CURTIME()

请参阅日期和时间函数

于 2013-02-22T15:05:20.580 回答
0

我使用了这个查询,它现在正在按照我的意愿工作......

 $result = mysql_query("SELECT id,date,start,end FROM jos_jxtc_appbook_appointments WHERE userident='$idusera' AND CONCAT(date,' ',start)> DATE_ADD( NOW( ) , INTERVAL 6 HOUR )");
 while($row = mysql_fetch_assoc($result))
 {

 echo '<div class="record" id="record-',$row['id'],'">
    <a href="?delete=',$row['id'],'" class="delete">Delete</a>
    <strong>',$row['date'],$space,$row['start'],$space,$row['end'],'</strong>
  </div>';

 }

this part DATE_ADD( NOW( ) , INTERVAL 6 HOUR ) is because time_zone in the mysql is different then mine(-6) and because i cant change timezone in the mysql directly(because i dont have super privileges).

于 2013-02-28T19:11:24.273 回答