从php数组匹配中检索价格范围内特定日期的数据

时间:2019-02-03 13:23:27

标签: php jquery arrays

我有mysql db,其中有很多关于Bookingdates的数据库-每个日期都有不同的价格。

我已经将数组从数据库中删除了-但是如何排序以使页面仅查看选定的日期价格-下面的数组是第一个日期-如您所见,有4种价格类型-7 14、21、28天。

我的目标是基于foreach循环创建一个选择选项,该循环必须返回给定日期的特定价格。

我知道我必须使用som jquery来实现该目标,但我不知道怎么做

我希望你们的专家能为您提供帮助-在此先感谢

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)

2 个答案:

答案 0 :(得分:0)

如果我对您的理解正确,那么您尝试通过到达和离开之间的天数来过滤结果。我建议在数据库查询中使用WHERE过滤器和MySQLs datediff函数(例如一周旅行的示例)来做到这一点:

SELECT [...] FROM [...] WHERE DATEDIFF(arival, departure) == 7;

如果需要所有条目,但按行程长度排序,则可以在ORDER BY子句中使用相同的函数:

SELECT [...] FROM [...] ORDER BY DATEDIFF(arival, departure);

答案 1 :(得分:0)

此SQL查询将帮助您过滤出数据。

SELECT price,arrival,departure FROM table_name;