值不会插入数据库中

时间:2016-02-10 12:16:08

标签: php mysql sql

我有一个会话日期数组存储到数据库中。我使用foreach将每个数组值保存到数据库中。

    $guestID = $_SESSION['guestID'];

$reservationQuery = mysqli_query($conn, "SELECT MAX(reservationID) AS resID FROM reservation WHERE guestID = $guestID;") OR die("Error in SELECT: ".mysqli_error($conn));

$reservationID = mysqli_fetch_array($reservationQuery);

    foreach($_SESSION['noOfRooms'] AS $type => $rooms){
        foreach($_SESSION['dates'] AS $dates){
            $reserves = mysqli_query($conn, "INSERT INTO roomreservation (reservationID, date_scheduled, roomDetailsNo, roomNo)
                                                SELECT $reservationID[resID], '$dates', roomDetailsNo, roomNo
                                                FROM rooms
                                                WHERE roomDetailsNo = $type AND room_status = 'available' LIMIT $rooms[0];") OR die("Error: ".mysqli_error($conn));
        }
        $update = mysqli_query($conn, "UPDATE rooms SET room_status = 'reserved' WHERE roomDetailsNo = $type AND room_status = 'available' LIMIT $rooms[0];") OR die("ERROR in Update: ".mysqli_error($conn));
    }

当我运行程序时。 table roomreservation是空的,没有保存我插入的任何值。我没有看到问题所在。有谁可以帮助我?

0 个答案:

没有答案