这是我的代码:
$total =0;
$b = 0;
$items = array();
foreach ($_SESSION["cart_products"] as $cart_itm)
{
$product_qty = $cart_itm["product_qty"];
$pid = $cart_itm["product_code"];
$results = mysql_query("SELECT * FROM Products WHERE ProductID = '".$pid."'");
while($row = mysql_fetch_array ($results)) {
$naam = $row["ProductName"];
$liters = $row["ProductLiters"];
$kleur = $row["ProductColor"];
$product_price = $row["ProductPrice"];
$beschrijving = $row["ProductDescription"];
$image = $row["ProductImage"];
$merk = $row["SupplierID"];
}
$items[] = array('pid' => $pid, 'qty' => $product_qty);
$subtotal = ($product_price * $product_qty);
$total = ($total + $subtotal);
?>
<div class="'.$bg_color.'">
<h1 class="ptitel" id="ptitel"><?= $naam ?></h1>
<p class="prijs" id="prijs">€<?= $product_price ?> x <?= $product_qty ?></p>
<p class="verzenden">Geen verzendkosten binnen Nederland</p>
<p id="pinfo"><?= $beschrijving ?></p>
<div id="liter">
<p class="text">Liters: <?= $liters ?></p>
</div>
<div id="kleur">
<p class="text">Kleur: <?= $kleur ?></p>
</div>
</div>
<?php
}
?>
</div>
<div class="left">
<?php
---------THIS HAS TO BE EXECUTED-----------
$orderid = mt_rand(100000,900000);
foreach ($items as $key => $value) {
mysql_query("INSERT INTO Bestellingen (pid, qty, orderid) VALUES ('".$value['pid']."', '".$value['qty']."', '".$orderid."')");
}
------------------END----------------------
?>
<form method="post" action="test.php">
<input type="text" name="realname" id="name" placeholder="Volledige naam" required/>
<input type="text" name="postcode" id="postcode" placeholder="Postcode" required/>
<input type="text" name="adres" id="adres" placeholder="Straatnaam+huisnummer" required/>
<input type="text" name="plaats" id="plaats" placeholder="Plaats" required/>
<input type="tel" name="telefoon" id="telefoon" placeholder="Mobiel nummer" required/>
<input type="email" name="email" id="email" placeholder="mail@voorbeeld.com" required/>
<textarea name="Message" placeholder="Heeft u wat te vertellen?"></textarea>
<input type="text" name="discount" id="discount" placeholder="Kortingscode"/>
<input type="submit" name="betaal" class="knop" value="BETALEN €<?= $total ?>" />
</form>
答案 0 :(得分:0)
额外建议:使用标记<?php ?>