您好我有购物车,我想在不同的php文件中打印项目名称。我试试这个。
<?php
if(!empty($_SESSION["cart"]))
{
$total = 0;
foreach($_SESSION["cart"] as $keys => $values)
{
$product_cart = $values["item_name"];
?>
<tr>
<td><?php echo $values["item_name"]; ?></td> <?php session_start(); $_SESSION['produktik'] = $values["item_name"] ; ?>
<td><?php echo $values["item_quantity"] ?></td>
<td><?php echo $values["product_price"]; ?>€</td>
<td><?php echo number_format($values["item_quantity"] * $values["product_price"], 2); ?>€</td>
<td><a href="shop.php?action=delete&id=<?php echo $values["product_id"]; ?>"><span class="text-danger">X</span></a></td>
</tr>
和第二个php文件是
<pre>
<?php
session_start();
echo $_SESSION['produktik'];
?>
</pre>