使用PHP进行多次查询

时间:2015-11-05 19:02:45

标签: php mysql

我是PHP新手,不确定我是否正确执行我的代码。虽然它确实有效,但我觉得我可能正在执行所述查询。看来如果没有关闭连接然后重新打开它我就不能有更多的查询。以下是我的代码,非常欢迎任何建议。

        //-----------------MAKE BOOKING-----------------//
        $AddBook = "CALL makeBooking((SELECT CustID FROM customer WHERE UserName = '$UserName'), '$PerfID', '$NumAdults', '$NumChilds', '$ColTicket', now());";
        if (mysqli_query($conn,$AddBook))
        {
            //----------------DEDUCT SEATS--------------//
            $SeatDeduction = "CALL deductSeats($TotalSeats,$PerfID)";
            mysqli_query($conn,$SeatDeduction);
            mysqli_close($conn);
            require ('connect.php'); 
            //-----------------GET BOOK ID--------------//
            $getBookID = "CALL getBookByUserName('$UserName')";
            $result2 = mysqli_query($conn, $getBookID);
            $Output2 = mysqli_fetch_assoc($result2);
            $BookID = $Output2['BookID'];
            mysqli_close($conn);
            require ('connect.php'); 
            $testing = "CALL setBookingPrice($BookID)";
            echo $testing;
            mysqli_query($conn,$testing);
            //---------------BOOKING CONFIRM------------//
            $ShowRef = 'The Booking Is Confirmed<p>Booking Reference Number: ' . $BookID . '<br>';
            $Confirm = $ShowRef;
        }

0 个答案:

没有答案