Autor Zpráva
elredin
Profil *
Dobrý den, mám na svých stránkách udělaný jednoduchý php košík, ale jakmile přidám stejnou věc dvakrát, nezvýší se mi množství ale celé se to přidá znovu. Funkce in_array mi bohužel nefunguje protože nevyhazuje ani vyskakovací okna že je toto pole už obsazeno. Přidávám zdrojový kód a snad by mi někdo pomohl.
[pre]<?php
session_start();
$connect = mysqli_connect("localhost", "root", "7s1u1ff3", "last-try");
if(isset($_POST["add_to_cart"]))
{
if(isset($_SESSION["shopping_cart"]))
{
$item_array_id = array_column($_SESSION["shopping_cart"], "id");
if(!in_array($_GET["id"], $item_array_id))
{
$count = count($_SESSION["shopping_cart"]);
$item_array = array(
'item_id' => $_GET["id"],
'item_name' => $_POST["hidden_name"],
'item_price' => $_POST["hidden_price"],
'item_quantity' => $_POST["quantity"]
);
$_SESSION["shopping_cart"][$count] = $item_array;
}
else
{
echo '<script>alert("Item Already Added")</script>';
echo '<script>window.location="pizza.php"</script>';
}
}
else
{
$item_array = array(
'id' => $_GET["id"],
'item_name' => $_POST["hidden_name"],
'item_price' => $_POST["hidden_price"],
'item_quantity' => $_POST["quantity"]
);
$_SESSION["shopping_cart"][0] = $item_array;
}
}
if(isset($_GET["action"]))
{
if($_GET["action"] == "delete")
{
foreach($_SESSION["shopping_cart"] as $keys => $values)
{
if($values["item_id"] == $_GET["id"])
{
unset($_SESSION["shopping_cart"][$keys]);
echo '<script>alert("Item Removed")</script>';
echo '<script>window.location="pizza.php"</script>';
}
}
}
}
?>
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Foundation | Welcome</title>
<link rel="stylesheet" href="css/foundation.css" />
<link rel="stylesheet" href="css/font-awesome.min.css" />
<script src="js/vendor/modernizr.js"></script>
</head>
<body>
<nav class="">
<header class="" ata-pg-id="4854">
<nav class="top-bar" data-topbar>
<ul class="title-area">
<li class="name">
<h1><a href="about.html">MOJE-CHALKA.cz</a></h1>
</li>
<li class="toggle-topbar menu-icon">
<a href="#">Menu</a>
</li>
</ul>
<section class="top-bar-section">
<!-- Right Nav Section -->
<ul class="right">
<li>
<a href="masa.html">DRUHY MASA</a>
</li>
<li>
<a href="about.html">O NÁS</a>
</li>
<li class="has-dropdown">
<a href="cart.php"> <i class="fa fa-shopping-cart fa-2x"><?php echo $items_in_cart; ?></i></a>
<ul class="dropdown">
<li>
<a href="?reset=reset">Resetovat košík</a>
</li>
</ul>
</li>
<li class="has-dropdown">
<a href="#">Uživatel</a>
<ul class="dropdown">
<li>
<a href="#">Přihlášení</a>
</li>
<li>
<a href="#">Vaše strava</a>
</li>
</ul>
</li>
</ul>
<!-- Left Nav Section -->
<ul class="left">
<li class="has-dropdown active">
<a href="#">KUPTE SI U NÁS</a>
<ul class="dropdown">
<li class="active">
<a href="#">Hamburgery</a>
</li>
<li class="active">
<a href="pizza.php">Pizzy</a>
</li>
<li class="active">
<a href="#">Párky</a>
</li>
</ul>
</li>
</ul>
</section>
</nav>
<img src="img/hamburger.png" class="medium-2 logo" />
<small>Jídlo pro vás za ty nejlepší ceny.</small>
<a href="blank.html"><h1 class="nakupujte">NAKUPUJTE</h1></a>
</header>
<section id="produkt" class="">
<div class="row">
<?php
$query = "SELECT * FROM produkty WHERE rubrika='pizza' ORDER BY id ASC";
$result = mysqli_query($connect, $query);
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
?>
<div class="medium-4 columns produkt">
<form method="post" action="pizza.php?action=add&id=<?php echo $row["id"]; ?>">
<img src="<?php echo $row["img"]; ?>" class="medium-4 produktimg" />
<h5><?php echo $row["jmeno"]; ?></h5>
<p><?php echo $row[popis] ?></p>
<p class="float-left kup-ted"> <input type="text" name="quantity" class="form-control" value="1" />
<input type="submit" name="add_to_cart" class="button" value="Přidej">
<input type="hidden" name="hidden_name" value="<?php echo $row["jmeno"]; ?>" />
<input type="hidden" name="hidden_price" value="<?php echo $row["cena"]; ?>" />
</form></p>
<p class="float-right cena">
<?php echo $row["cena"];echo "Kč"; ?></p>
</div>
<?php }} ?>
</div>
</section>
<section id="shopping-carter">
<table class="medium-6">
<tr>
<th width="40%">Item Name</th>
<th width="10%">Quantity</th>
<th width="20%">Price</th>
<th width="15%">Total</th>
<th width="5%">Action</th>
</tr>
<?php
if(!empty($_SESSION["shopping_cart"]))
{
$total = 0;
$quantity = 0;
foreach($_SESSION["shopping_cart"] as $keys => $values)
{
?>
<tr>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"]; ?></td>
<td>$ <?php echo $values["item_price"]; ?></td>
<td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">Remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">Total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>
?>>
}
?>>
<?php
}
?>>
</tr>
<?php
}
?>>
<td></td>
</tr>
<?php
}
?>>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
<td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
<td>$ <?php echo $values["item_price"]; ?></td>
<td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
<td><?php echo $values["item_quantity"]; ?></td>
<td>$ <?php echo $values["item_price"]; ?></td>
<td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"]; ?></td>
<td>$ <?php echo $values["item_price"]; ?></td>
<td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
<tr>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"]; ?></td>
<td>$ <?php echo $values["item_price"]; ?></td>
<td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
?>
<tr>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"]; ?></td>
<td>$ <?php echo $values["item_price"]; ?></td>
<td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
{
?>
<tr>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"]; ?></td>
<td>$ <?php echo $values["item_price"]; ?></td>
<td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
foreach($_session["shopping_cart"] as $keys => $values)
{
?>
<tr>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"]; ?></td>
<td>$ <?php echo $values["item_price"]; ?></td>
<td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
$quantity = 0;
foreach($_session["shopping_cart"] as $keys => $values)
{
?>
<tr>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"]; ?></td>
<td>$ <?php echo $values["item_price"]; ?></td>
<td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
$total = 0;
$quantity = 0;
foreach($_session["shopping_cart"] as $keys => $values)
{
?>
<tr>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"]; ?></td>
<td>$ <?php echo $values["item_price"]; ?></td>
<td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
{
$total = 0;
$quantity = 0;
foreach($_session["shopping_cart"] as $keys => $values)
{
?>
<tr>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"]; ?></td>
<td>$ <?php echo $values["item_price"]; ?></td>
<td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
if(!empty($_session["shopping_cart"]))
{
$total = 0;
$quantity = 0;
foreach($_session["shopping_cart"] as $keys => $values)
{
?>
<tr>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"]; ?></td>
<td>$ <?php echo $values["item_price"]; ?></td>
<td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
<?php
if(!empty($_session["shopping_cart"]))
{
$total = 0;
$quantity = 0;
foreach($_session["shopping_cart"] as $keys => $values)
{
?>
<tr>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"]; ?></td>
<td>$ <?php echo $values["item_price"]; ?></td>
<td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
</tr>
<?php
if(!empty($_session["shopping_cart"]))
{
$total = 0;
$quantity = 0;
foreach($_session["shopping_cart"] as $keys => $values)
{
?>
<tr>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"]; ?></td>
<td>$ <?php echo $values["item_price"]; ?></td>
<td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
<th width="5%">action</th>
</tr>
<?php
if(!empty($_session["shopping_cart"]))
{
$total = 0;
$quantity = 0;
foreach($_session["shopping_cart"] as $keys => $values)
{
?>
<tr>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"]; ?></td>
<td>$ <?php echo $values["item_price"]; ?></td>
<td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
<th width="15%">total</th>
<th width="5%">action</th>
</tr>
<?php
if(!empty($_session["shopping_cart"]))
{
$total = 0;
$quantity = 0;
foreach($_session["shopping_cart"] as $keys => $values)
{
?>
<tr>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"]; ?></td>
<td>$ <?php echo $values["item_price"]; ?></td>
<td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
<th width="20%">price</th>
<th width="15%">total</th>
<th width="5%">action</th>
</tr>
<?php
if(!empty($_session["shopping_cart"]))
{
$total = 0;
$quantity = 0;
foreach($_session["shopping_cart"] as $keys => $values)
{
?>
<tr>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"]; ?></td>
<td>$ <?php echo $values["item_price"]; ?></td>
<td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
<th width="10%">quantity</th>
<th width="20%">price</th>
<th width="15%">total</th>
<th width="5%">action</th>
</tr>
<?php
if(!empty($_session["shopping_cart"]))
{
$total = 0;
$quantity = 0;
foreach($_session["shopping_cart"] as $keys => $values)
{
?>
<tr>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"]; ?></td>
<td>$ <?php echo $values["item_price"]; ?></td>
<td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
<td align="right"></td>
<td align="right">$ <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>>
<th width="40%">item name</th>
<th width="10%">quantity</th>
<th width="20%">price</th>
<th width="15%">total</th>
<th width="5%">action</th>
</tr>
<?php
if(!empty($_session["shopping_cart"]))
{
$total = 0;
$quantity = 0;
foreach($_session["shopping_cart"] as $keys => $values)
{
?>
<tr>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"]; ?></td>
<td>$ <?php echo $values["item_price"]; ?></td>
<td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td>
<td><a href="pizza.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td align="right">total</td>
<td align="right">
<?php echo $quantity; ?>
</td>
Xanomes_
Profil *
Když pominu fakt, že jsi nám sem dal 4 obrazovky textu, je v kódu spousta chyb, buď tvojí neschopností zmáčknout úspěšně Ctrl + C a Ctrl + V, nebo tím, že je skript pokažený už na straně serveru. Na spoustě míst obsahuje osamocené { a díky úkazům jako je ?>> jsem při procházení skriptu znejistěl, zda se skutečně jedná o PHP... oprav si to a pak možná přijdeme na to, proč ti to nefunguje.

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm: