Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在不同日期内从mysql数据库获取数据?_Php_Html_Mysql - Fatal编程技术网

Php 如何在不同日期内从mysql数据库获取数据?

Php 如何在不同日期内从mysql数据库获取数据?,php,html,mysql,Php,Html,Mysql,我有一个名为“预订”的表。我有以下值 res_id hotel_id room_type start end qty 1048 1 standard 2015-05-18 2015-05-20 1 我有一个酒店搜索选项。如果用户输入开始日期为2015-05-16和结束日期为2015-05-19,并搜索my bookedrooms.php,则标准房间类型显示零值。我的sql查询是 $sql1 = mysql_query("select * from

我有一个名为“预订”的表。我有以下值

res_id hotel_id room_type start      end        qty
  1048        1 standard  2015-05-18 2015-05-20   1
我有一个酒店搜索选项。如果用户输入开始日期为2015-05-16和结束日期为2015-05-19,并搜索my bookedrooms.php,则标准房间类型显示零值。我的sql查询是

$sql1 = mysql_query("select * from reservations where start >= '".$start."' 


end是开始和结束的实际日期吗?如果是这样的话,你可能应该投下它们

"select * from reservations where start >= date('".$start."') and end <= date('".$end."') and room_type = 'standard' "

“从开始>=date(“$start.”)的预订中选择*)结束我不明白这个问题。这与javascript或jquery有什么关系?我想得到两天之间的房间类型数量?你能在两个字段上做一个中间值吗?他有开始和结束日期,没有可用的日期。人使用中间值时出错。然后请尝试下面的Airclo问题。你能回显或错误记录$start an吗d$end以确保它们是您期望的值?您能更具体地说明“不工作”吗?仍然返回0结果?返回sql异常?什么?它为2015-05-17和2005-05-19之间的标准房间类型提供0值。您是指2015-05-19吗?是的,我想获取上述日期范围内的标准房间数量。
start >= '".$start."' and end <= '".$end."' 
"select * from reservations where start >= date('".$start."') and end <= date('".$end."') and room_type = 'standard' "