仅在foreach循环

时间:2017-12-05 03:10:19

标签: php mysqli foreach

我无法在名为bookedseattbl的表中插入多行。我正在使用foreach循环,但它只插入一行。第一个插入查询执行正常。

<?php
$seats=explode(',',$_SESSION['seats']);
mysqli_query($con, "INSERT INTO bookingtbl(UserId, DetailsId, Amount, PaymentStatus) VALUES ('$uid', (SELECT detailstbl.DetailsId FROMdetailstbl
                    JOIN movietbl ON detailstbl.MovieId=movietbl.id AND movietbl.id = '$movieid'
                    JOIN theatretbl ON detailstbl.TheatreId=theatretbl.TheatreId AND theatretbl.TheatreName LIKE '$theatre%'
                    JOIN timingtbl ON timingtbl.TimingId=detailstbl.TimingId AND timingtbl.Time = '$time'),'$amt',1)");
$a=mysqli_insert_id($con);
foreach ($seats as $x)
{
    mysqli_query($con, "INSERT INTO bookedseattbl(BookingId, SeatId) VALUES ('$a', (SELECT * FROM seatstbl WHERE SeatNo='$x')))");
}
?>

如果我尝试在绝对值中放置一个绝对值,它会按预期执行,但只能在使用select查询时执行一次。

0 个答案:

没有答案