Jump to content

Shopping cart


jay_bo

Recommended Posts

Could anyone help me on removing and update items in my shopping cart.....

 

This is how items are added...

echo '<div id="cart_container">';
echo '<div id="cart">';
$cost = number_format($_SESSION["cost"],2,".",",");
echo '<form name="cart" method="post" action="shopping-cart.php" >';
echo '<p class="center"><strong>SHOPPING CART</strong></p>';
echo '<p>No of Items: <strong>'.$_SESSION['products'].'</strong><br/>Total Price: <strong>£'.$_SESSION['cost'].'</strong></p>';
echo '<input type="hidden" name="price" value="'.$row["price"].'">';
echo '<p class="button"><input type="submit" name="Submit" value="Check Out"></p>';
echo '</form>';
echo '<form name="cart" method="post" action="logout.php" >';
echo '<p class="button"><input type="submit" name="Submit" value="Logout"></p>';
echo '</form>';
echo '</div>';
echo '</div>';

 

This is my shopping cart.......

	<?php

	$items = explode(",",$_SESSION["order"]);

$sql="SELECT * FROM products";
$result=mysql_query($sql);


while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
for( $i = 0; $i < count($items); ++$i )
{
	echo '<form id="form1" name="form1" method="post" action="checkout.php">';
	echo '<div id="products">';
	if ($items[$i]==$row['product_id'])
	{
	echo $row['title']. ' - £'.$row['price'] ;
	}
	echo '</div>';
}
}			  
	echo '<br />';
		  echo '<input type="submit" name="Submit" value="Pay for Items" />';
	echo '</form>';
	echo '<form id="form1" name="form1" method="post" action="logout.php">';
				  echo '<input type="submit" name="Submit" value="Empty Cart" />';
	echo '</form>';
	?>

 

Many thanks

Link to comment
https://forums.phpfreaks.com/topic/196003-shopping-cart/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.