Retrive在一个价格范围从PHP阵列匹配到特定日期数据
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Retrive在一个价格范围从PHP阵列匹配到特定日期数据相关的知识,希望对你有一定的参考价值。
我有mysql数据库有很多关于bookingdates数据的基础上的 - 不同的价格连接到每个日期。
我已经得到了阵列出来的分贝的 - 但我怎么样让页面只查看选定日期价格 - 下面阵列是第一次约会 - 你可以看到有4种价格上涨 - 7,14,21 ,28天。
我的目标是创建一个基于foreach循环,其必须返回具体价格给定日期的选择选项。
我知道我必须使用SOM jQuery来optain这一目标,但我无法弄清楚如何
我希望你们中的一些专家能帮助您 - 在此先感谢
object(stdClass)[11646]
public 'lodging_id' => string '2' (length=1)
public 'lan' => string '1' (length=1)
public 'arrival' => string '2019-02-02' (length=10)
public 'departure' => string '2019-02-09' (length=10)
public 'unittype_id' => string '2' (length=1)
public 'duration' => string '7' (length=1)
public 'currency' => string 'DKK' (length=3)
public 'price' => string '3500' (length=4)
public 'winterrulewarning' => string 'false' (length=5)
public 'isavailable' => string 'true' (length=4)
public 'priority' => string 'Normal' (length=6)
public 'normalprice' => string '3500' (length=4)
public 'hasdiscount' => string 'false' (length=5)
public 'pets' => string '0' (length=1)
public 'infants' => string '0' (length=1)
public 'children' => string '0' (length=1)
public 'adults' => string '2' (length=1)
public 'languageid' => string '1' (length=1)
public 'isregularweek' => string 'true' (length=4)
public 'boardtypeid' => string '' (length=0)
public 'booking_status' => string 'Booking' (length=7)
public 'dayswithdiscount' => string '0' (length=1)
public 'dayswithaddition' => string '0' (length=1)
public 'created' => string '2019-02-02 08:12:39' (length=19)
public 'updated' => string '0000-00-00 00:00:00' (length=19)
public 'disabled' => string '2019-02-02 17:28:01' (length=19)
public 'session' => string '3556' (length=4)
public 'status' => string '0' (length=1)
1 =>
object(stdClass)[11647]
public 'lodging_id' => string '2' (length=1)
public 'lan' => string '1' (length=1)
public 'arrival' => string '2019-02-02' (length=10)
public 'departure' => string '2019-02-16' (length=10)
public 'unittype_id' => string '2' (length=1)
public 'duration' => string '14' (length=2)
public 'currency' => string 'DKK' (length=3)
public 'price' => string '7000' (length=4)
public 'winterrulewarning' => string 'false' (length=5)
public 'isavailable' => string 'true' (length=4)
public 'priority' => string 'Normal' (length=6)
public 'normalprice' => string '7000' (length=4)
public 'hasdiscount' => string 'false' (length=5)
public 'pets' => string '0' (length=1)
public 'infants' => string '0' (length=1)
public 'children' => string '0' (length=1)
public 'adults' => string '2' (length=1)
public 'languageid' => string '1' (length=1)
public 'isregularweek' => string 'true' (length=4)
public 'boardtypeid' => string '' (length=0)
public 'booking_status' => string 'Booking' (length=7)
public 'dayswithdiscount' => string '0' (length=1)
public 'dayswithaddition' => string '0' (length=1)
public 'created' => string '2019-02-02 08:12:39' (length=19)
public 'updated' => string '0000-00-00 00:00:00' (length=19)
public 'disabled' => string '2019-02-02 17:28:01' (length=19)
public 'session' => string '3556' (length=4)
public 'status' => string '0' (length=1)
2 =>
object(stdClass)[11648]
public 'lodging_id' => string '2' (length=1)
public 'lan' => string '1' (length=1)
public 'arrival' => string '2019-02-02' (length=10)
public 'departure' => string '2019-02-23' (length=10)
public 'unittype_id' => string '2' (length=1)
public 'duration' => string '21' (length=2)
public 'currency' => string 'DKK' (length=3)
public 'price' => string '10500' (length=5)
public 'winterrulewarning' => string 'false' (length=5)
public 'isavailable' => string 'true' (length=4)
public 'priority' => string 'Normal' (length=6)
public 'normalprice' => string '10500' (length=5)
public 'hasdiscount' => string 'false' (length=5)
public 'pets' => string '0' (length=1)
public 'infants' => string '0' (length=1)
public 'children' => string '0' (length=1)
public 'adults' => string '2' (length=1)
public 'languageid' => string '1' (length=1)
public 'isregularweek' => string 'true' (length=4)
public 'boardtypeid' => string '' (length=0)
public 'booking_status' => string 'Booking' (length=7)
public 'dayswithdiscount' => string '0' (length=1)
public 'dayswithaddition' => string '0' (length=1)
public 'created' => string '2019-02-02 08:12:40' (length=19)
public 'updated' => string '0000-00-00 00:00:00' (length=19)
public 'disabled' => string '2019-02-02 17:28:01' (length=19)
public 'session' => string '3556' (length=4)
public 'status' => string '0' (length=1)
3 =>
object(stdClass)[11649]
public 'lodging_id' => string '2' (length=1)
public 'lan' => string '1' (length=1)
public 'arrival' => string '2019-02-02' (length=10)
public 'departure' => string '2019-03-02' (length=10)
public 'unittype_id' => string '2' (length=1)
public 'duration' => string '28' (length=2)
public 'currency' => string 'DKK' (length=3)
public 'price' => string '14000' (length=5)
public 'winterrulewarning' => string 'false' (length=5)
public 'isavailable' => string 'true' (length=4)
public 'priority' => string 'Normal' (length=6)
public 'normalprice' => string '14000' (length=5)
public 'hasdiscount' => string 'false' (length=5)
public 'pets' => string '0' (length=1)
public 'infants' => string '0' (length=1)
public 'children' => string '0' (length=1)
public 'adults' => string '2' (length=1)
public 'languageid' => string '1' (length=1)
public 'isregularweek' => string 'true' (length=4)
public 'boardtypeid' => string '' (length=0)
public 'booking_status' => string 'Booking' (length=7)
public 'dayswithdiscount' => string '0' (length=1)
public 'dayswithaddition' => string '0' (length=1)
public 'created' => string '2019-02-02 08:12:40' (length=19)
public 'updated' => string '0000-00-00 00:00:00' (length=19)
public 'disabled' => string '2019-02-02 17:28:01' (length=19)
public 'session' => string '3556' (length=4)
public 'status' => string '0' (length=1)
object(stdClass)[11646]
public 'lodging_id' => string '2' (length=1)
public 'lan' => string '1' (length=1)
public 'arrival' => string '2019-02-02' (length=10)
public 'departure' => string '2019-02-09' (length=10)
public 'unittype_id' => string '2' (length=1)
public 'duration' => string '7' (length=1)
public 'currency' => string 'DKK' (length=3)
public 'price' => string '3500' (length=4)
public 'winterrulewarning' => string 'false' (length=5)
public 'isavailable' => string 'true' (length=4)
public 'priority' => string 'Normal' (length=6)
public 'normalprice' => string '3500' (length=4)
public 'hasdiscount' => string 'false' (length=5)
public 'pets' => string '0' (length=1)
public 'infants' => string '0' (length=1)
public 'children' => string '0' (length=1)
public 'adults' => string '2' (length=1)
public 'languageid' => string '1' (length=1)
public 'isregularweek' => string 'true' (length=4)
public 'boardtypeid' => string '' (length=0)
public 'booking_status' => string 'Booking' (length=7)
public 'dayswithdiscount' => string '0' (length=1)
public 'dayswithaddition' => string '0' (length=1)
public 'created' => string '2019-02-02 08:12:39' (length=19)
public 'updated' => string '0000-00-00 00:00:00' (length=19)
public 'disabled' => string '2019-02-02 17:28:01' (length=19)
public 'session' => string '3556' (length=4)
public 'status' => string '0' (length=1)
1 =>
object(stdClass)[11647]
public 'lodging_id' => string '2' (length=1)
public 'lan' => string '1' (length=1)
public 'arrival' => string '2019-02-02' (length=10)
public 'departure' => string '2019-02-16' (length=10)
public 'unittype_id' => string '2' (length=1)
public 'duration' => string '14' (length=2)
public 'currency' => string 'DKK' (length=3)
public 'price' => string '7000' (length=4)
public 'winterrulewarning' => string 'false' (length=5)
public 'isavailable' => string 'true' (length=4)
public 'priority' => string 'Normal' (length=6)
public 'normalprice' => string '7000' (length=4)
public 'hasdiscount' => string 'false' (length=5)
public 'pets' => string '0' (length=1)
public 'infants' => string '0' (length=1)
public 'children' => string '0' (length=1)
public 'adults' => string '2' (length=1)
public 'languageid' => string '1' (length=1)
public 'isregularweek' => string 'true' (length=4)
public 'boardtypeid' => string '' (length=0)
public 'booking_status' => string 'Booking' (length=7)
public 'dayswithdiscount' => string '0' (length=1)
public 'dayswithaddition' => string '0' (length=1)
public 'created' => string '2019-02-02 08:12:39' (length=19)
public 'updated' => string '0000-00-00 00:00:00' (length=19)
public 'disabled' => string '2019-02-02 17:28:01' (length=19)
public 'session' => string '3556' (length=4)
public 'status' => string '0' (length=1)
2 =>
object(stdClass)[11648]
public 'lodging_id' => string '2' (length=1)
public 'lan' => string '1' (length=1)
public 'arrival' => string '2019-02-02' (length=10)
public 'departure' => string '2019-02-23' (length=10)
public 'unittype_id' => string '2' (length=1)
public 'duration' => string '21' (length=2)
public 'currency' => string 'DKK' (length=3)
public 'price' => string '10500' (length=5)
public 'winterrulewarning' => string 'false' (length=5)
public 'isavailable' => string 'true' (length=4)
public 'priority' => string 'Normal' (length=6)
public 'normalprice' => string '10500' (length=5)
public 'hasdiscount' => string 'false' (length=5)
public 'pets' => string '0' (length=1)
public 'infants' => string '0' (length=1)
public 'children' => string '0' (length=1)
public 'adults' => string '2' (length=1)
public 'languageid' => string '1' (length=1)
public 'isregularweek' => string 'true' (length=4)
public 'boardtypeid' => string '' (length=0)
public 'booking_status' => string 'Booking' (length=7)
public 'dayswithdiscount' => string '0' (length=1)
public 'dayswithaddition' => string '0' (length=1)
public 'created' => string '2019-02-02 08:12:40' (length=19)
public 'updated' => string '0000-00-00 00:00:00' (length=19)
public 'disabled' => string '2019-02-02 17:28:01' (length=19)
public 'session' => string '3556' (length=4)
public 'status' => string '0' (length=1)
3 =>
object(stdClass)[11649]
public 'lodging_id' => string '2' (length=1)
public 'lan' => string '1' (length=1)
public 'arrival' => string '2019-02-02' (length=10)
public 'departure' => string '2019-03-02' (length=10)
public 'unittype_id' => string '2' (length=1)
public 'duration' => string '28' (length=2)
public 'currency' => string 'DKK' (length=3)
public 'price' => string '14000' (length=5)
public 'winterrulewarning' => string 'false' (length=5)
public 'isavailable' => string 'true' (length=4)
public 'priority' => string 'Normal' (length=6)
public 'normalprice' => string '14000' (length=5)
public 'hasdiscount' => string 'false' (length=5)
public 'pets' => string '0' (length=1)
public 'infants' => string '0' (length=1)
public 'children' => string '0' (length=1)
public 'adults' => string '2' (length=1)
public 'languageid' => string '1' (length=1)
public 'isregularweek' => string 'true' (length=4)
public 'boardtypeid' => string '' (length=0)
public 'booking_status' => string 'Booking' (length=7)
public 'dayswithdiscount' => string '0' (length=1)
public 'dayswithaddition' => string '0' (length=1)
public 'created' => string '2019-02-02 08:12:40' (length=19)
public 'updated' => string '0000-00-00 00:00:00' (length=19)
public 'disabled' => string '2019-02-02 17:28:01' (length=19)
public 'session' => string '3556' (length=4)
public 'status' => string '0' (length=1)
答案
如果我理解正确的话,你正在尝试通过arival和出发之间的天数来筛选结果。我yould建议使用WHERE过滤器和MySQLs datediff
功能(例如一个星期的旅行)在数据库查询中这样做:
SELECT [...] FROM [...] WHERE DATEDIFF(arival, departure) == 7;
如果你想所有条目,但行程长度排序,可以在ORDER BY子句中使用相同的功能:
SELECT [...] FROM [...] ORDER BY DATEDIFF(arival, departure);
另一答案
这个SQL查询将帮助您筛选出数据。
SELECT price,arrival,departure FROM table_name;
以上是关于Retrive在一个价格范围从PHP阵列匹配到特定日期数据的主要内容,如果未能解决你的问题,请参考以下文章
点击 CollectionView Cell 按钮以播放来自特定阵列的声音并从特定阵列复制电影