<?php session_start(); error_reporting(E_ALL); ini_set('display_errrors', '1'); // session_destroy(); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <meta name="description" content="" /> <meta name="author" content="" /> <title>Cart</title> <!-- Favicon--> <link rel="icon" type="image/x-icon" href="assets/favicon.ico" /> <!-- Bootstrap icons--> <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css" rel="stylesheet" /> <!-- Core theme CSS (includes Bootstrap)--> <link href="css/styles.css" rel="stylesheet" /> <link href="css/stylecart.css" rel="stylesheet" /> <script src="js/scripts.js" async></script> </head> <style> body { font-size: 20px; } </style> <body> <a class="back" href="index.php"> class="bi bi-arrow-left-circle-fill bi-5x"></a> <?php include "config.php"; ?> <div class="text-center" style="font-size: 100px;">🛍</div> <h2 class="text-center">Winkelmandje</h2><br> <section class="container content-section"> <!-- <h2 class="section-header">CART</h2> --> <div class="cart-row"> ITEM PRICE QUANTITY </div> <?php $broodjes_ID = $_GET['broodjes_ID']; // //$basket = $_SESSION['basket'][$i]; $sql = "SELECT broodjes_ID, broodnaam, prijs FROM broodjes WHERE broodjes_ID = ?"; // uitvoeren, resultaat tonen in tabel. $stmt = $conn->prepare($sql); $stmt->bind_param("i", $broodjes_ID); $stmt->execute(); $result = $stmt->get_result(); // get the mysqli result //while loop zorgt er volgens mij voor dat hij blijft optellen if($row = $result-> fetch_assoc()){ $sum = 0; echo '<div class="cart-items">'; echo '<div class="cart-row">'; echo '<div class="cart-item cart-column">'; echo ''. $row['broodnaam'] . ''; echo '</div>'; echo ' €'. $row['prijs'] . ''; $sum = $row['prijs']; echo '<form name="quantity" method="POST" action="action_page.php"> <select id="quantity" value="quantity"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> </form> '; echo '</div>'; echo '</div>'; //$sumtotal = $sum * 2; echo '<br>'; echo '<div class="text-center"> <button class="btn btn-outline-primary" type="button"><a href="bestellen.php?broodjes_ID='. $row['broodjes_ID'].'" method="POST">PURCHASE</a></button> </div>'; } ?> <div class="cart-total"> class="cart-total-title">Total € <?php $sumtotal = $_GET['sumtotal']; echo $sumtotal;?> </div> <!-- <div class="cart-total"> class="cart-total-title">Total € 0 </div> --> </section> </body>
<?php $sql = "SELECT broodjes_ID, broodnaam, prijs FROM broodjes WHERE broodjes_ID = ?"; // uitvoeren, resultaat tonen in tabel. $stmt = $conn->prepare($sql); $stmt->bind_param("i", $broodjes_ID); $stmt->execute(); $result = $stmt->get_result(); // get the mysqli result //while loop zorgt er volgens mij voor dat hij blijft optellen if($row = $result-> fetch_assoc()){ if($_POST['quantity']){ if ("quantity" == 1) { $Qty = 1; $sumtotal = $Qty * $row['prijs']; echo '<a href="cart.php?prijs='. $sumtotal.'" method="POST">'; echo $sumtotal; } elseif ("quantity" == 2) { $Qty = 2; $sumtotal = $Qty * $row['prijs']; echo '<a href="cart.php?prijs='. $sumtotal.'" method="POST">'; echo $sumtotal; } elseif ("quantity" == 3) { $Qty = 3; $sumtotal = $Qty * $row['prijs']; echo '<a href="cart.php?prijs='. $sumtotal.'" method="POST">'; echo $sumtotal; }elseif ("quantity" == 4){ $Qty = 4; $sumtotal = $Qty * $row['prijs']; echo '<a href="cart.php?prijs='. $sumtotal.'" method="POST">'; echo $sumtotal; } } } ?>
$Qty = 2; $Price = 3.00; $Total = $Qty * $Price;
select
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)