im developing shopping cart project , where everything works fine . i would like to ask i thing that how to insert all cart products in to database one by one
below is the code which i try but it only insert first session row not inserting all.
here is the code:
$User_Email=$_SESSION['User_Email'];
$date=date("d-m-Y");
foreach($_SESSION["shopping_cart"] as $v){
$sql = "INSERT INTO reservation (check_in,check_out,room_id,hotel_id,User_Email,date)
values
('{$v['Checkin']}','{$v['Checkout']}','{$v['room_id']}','{$v['room_id']}','$User_Email','$date')";
$update = mysqli_query($connection, $sql);
if ($update) {
$_SESSION['success'] = 'Information updated successfully';
header("location: my_account.php");
exit;
} else {
$_SESSION['errormsg'] = 'Someting is wrong in updating your Information, Please try again later.';
header("location: my_account.php");
exit;
}}
please tell me how to insert all cart values in to database.
thanks in advance.