gpt4 book ai didi

javascript - 制作日历的问题

转载 作者:行者123 更新时间:2023-11-30 21:58:46 25 4
gpt4 key购买 nike

我试图制作一个带有日历的预订系统,但现在有点卡住了。这个过程或多或少是这样的

首先,我构建一个链接。

function __construct($link) {
$this->link = $link;
}


然后我做日历

function make_calendar($selected_date, $back, $forward, $day, $month, $year) {

// $day, $month and $year are the $_GET variables in the URL
$this->day = $day;
$this->month = $month;
$this->year = $year;

// $back and $forward are Unix Timestamps of the previous / next month, used to give the back arrow the correct month and year
$this->selected_date = $selected_date;
$this->back = $back;
$this->back_month = date("m", $back);
$this->back_year = date("Y", $back); // Minus one month back arrow

$this->forward = $forward;
$this->forward_month = date("m", $forward);
$this->forward_year = date("Y", $forward); // Add one month forward arrow

// Make the booking array
$this->make_booking_array($year, $month);

}


最后,我进行预订

function make_booking_array($year, $month, $j = 0) { 

$stmt = $this->link->prepare("SELECT name, date, start FROM bookings WHERE date LIKE CONCAT(?, '-', ?, '%')");

$this->is_slot_booked_today = 0; // Defaults to 0

$stmt->bind_param('ss', $year, $month);
$stmt->bind_result($name, $date, $start);
$stmt->execute();
$stmt->store_result();

while($stmt->fetch()) {

$this->bookings_per_day[$date][] = $start;

$this->bookings[] = array(
"name" => $name,
"date" => $date,
"start" => $start
);

// Used by the 'booking_form' function later to check whether there are any booked slots on the selected day
if($date == $this->year . '-' . $this->month . '-' . $this->day) {
$this->is_slot_booked_today = 1;
}

}

// Calculate how many slots there are per day
$this->slots_per_day = 0;
for($i = strtotime($this->booking_start_time); $i<= strtotime($this->booking_end_time); $i = $i + $this->booking_frequency * 60) {
$this->slots_per_day ++;
}

$stmt->close();
$this->make_days_array($year, $month);

} // Close function


错误出现在此最后一个函数上:

Fatal error: Call to a member function bind_param() on boolean in C:\xampp\htdocs\dashboard\aa\calendar_new\classes\class_calendar.php on line 73


在准备$ stm之后。我的想法是 construction of the link不正确,或者我在 prepare()函数上犯了一个错误

谢谢你的帮助。

最佳答案

一件事是您需要在bind_result之前执行

   $stmt->bind_param('ss', $year, $month); 
$stmt->execute();
$stmt->bind_result($name, $date, $start);

关于javascript - 制作日历的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44140190/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com