Ich möchte Warenkorb mit einfachen PHP und MySQL-Code hier ist ein Code, um den Warenkorb anzuzeigen, und ich möchte das Element in einer Tabelle und mit einer Schaltfläche zum Entfernen für sehen jeder hier habe ich einen Wagen und seesion ist dort möchte ich ein einfaches Warenkorb so kann mir jemand sagen, wie ich eine Entfernen-Taste auf jedes Element anzeigen und auch den Artikel in den Warenkorb zeigenWarenkorb, die Artikel mit der Schaltfläche zum Entfernen für jede von ihnen zeigen
<?php
session_start();
include_once("config.php");
if(empty($_SESSION['cart']))
$_SESSION['cart'] = array();
if(isset($_POST['product_code'])){
\t \t $product_code = $_POST["product_code"];
\t \t $product_name = $_POST["product_name"];
\t \t $product_qty = $_POST["product_qty"];
\t \t $product_price = $_POST["price"];
\t \t $product_color = $_POST["product_color"];
\t \t $_SESSION['cart'][] = array('name' => $product_name, 'product_code' => $product_code, 'qnty' => $product_qty, 'color' =>$product_color, 'price' => $product_price);
\t \t
\t \t
\t \t
}
print_r ($_SESSION['cart']);/*header("Location: view_cart.php");*/
if(isset($_POST['empty']) ){
unset($_SESSION["cart"]);
\t \t \t
\t }
\t
\t
?>
<html>
<head>
</head>
<body>
<form method="POST" action="cart.php"><div align="center"><button type="remove" name="empty" >empty</button></div>
<a href="ppage.php">back </a>
<table width="100%" cellpadding="6" cellspacing="0"><thead><tr><th>Quantity</th><th>Name</th><th>Price</th><th>code</th><th>colour</th><th>remove</th></tr></thead>
<tbody>
<?php
foreach($_SESSION['cart'] as $itm=>$val)
\t echo "<thead>";
\t \t echo"<tr>";
\t \t \t echo '<td>'.$val['$qnty'].'</td>';
\t \t \t echo '<td>'.$val['name'].'</td>';
\t \t \t echo '<td>'.$val['price'].'</td>';
\t \t \t echo '<td>'.$val['product_code'].'</td>';
\t \t \t echo '<td>'.$val['color'].'</td>';
\t \t \t /*echo '<td>'<a href="?remove=<?php echo $itm; ?>">remove</a>'</td>'
\t \t \t \t */
\t \t \t \t
\t \t \t \t if (isset($_POST['remove'])){
\t
\t \t \t \t unset($_SESSION['cart'][$_POST['remove']]);}
\t \t \t /*echo \t <div align="right"><button type="remove" name="remove" >remove</button></div> */
\t \t \t echo '</tr>';
\t \t \t echo "<thead>";
\t
\t \t \t
\t \t ?> \t
echo \t <div align="right"><button type="remove" name="remove" >remove</button></div>
\t \t \t \t echo '<td>'<a href="?remove=<?php echo $itm; ?>">remove</a>'</td>'
\t \t \t \t \t
</form>
</tbody>
</body>
</html>
Bitte verwenden Sie Interpunktion in Ihrer Beschreibung. Es ist wirklich schwer zu lesen, wenn alles in einem Satz ist. –
jetzt kann ich die Frage bearbeiten –