在这里我需要检查我的数据库是否达到当前日期然后我必须执行编码,否则必须跳过
function list_hotel_default($country,$city,$location,$fromdate,$todate,$roomtype,$adults,$child_no)
{
$condition="country='$country' AND city='$city' AND location='$location' AND show2web='1' AND expiry_date is greater than current date";
$active_hotel_get_qry = mysql_query("SELECT * FROM hoteldetails WHERE ".$condition);
}
if else然后它不应该执行
怎么做?
答案 0 :(得分:1)
如果您想仅使用日期值进行检查,则可以使用
function list_hotel_default($country,$city,$location,$fromdate,$todate,$roomtype,$adults,$child_no)
{
$condition="country='$country' AND city='$city' AND location='$location' AND show2web='1' AND expiry_date > CURDATE()";
$active_hotel_get_qry = mysql_query("SELECT * FROM hoteldetails WHERE ".$condition);
}
答案 1 :(得分:0)
您可以使用MySQLs inbuit date函数 - 特别是now函数,它返回当前时间和日期:
$condition="country='$country' AND city='$city' AND location='$location'
AND show2web='1' AND expiry_date > now()";
这假设expiry_date
实际上是日期或日期时间字段。