Jump to content

Recommended Posts

Hi,

I'm trying to make a simple online shop where we can add the products to a shopping cart. So, the visitors choose the products and can view the product on a basket. The table will show the quality, name and total price.

 

The problem is I got 2 extra rows with 2 qualities, 0 price and no product, above the selected products rows. I can't delete those either. This is the basket.php script:

<?php 
include "functions_cart.php";
$totalvalue = 0;
session_start();
if (!isset($_SESSION["cart"])) {
$_SESSION["cart"] = NULL;
}

if (validate() == TRUE && $_SESSION["cart"] != NULL) {

foreach ($_SESSION["cart"] as $key => $session_data) {

	list($ses_id, $ses_quan) = $session_data;
		db_connect();
		$sel_products = mysql_query("SELECT * FROM $mysql_tablename WHERE prod_id=".$ses_id."");
		$item = mysql_fetch_array($sel_products);

		$totalvalue = $totalvalue + ($item["price"]*$ses_quan);
		$subtotal = ($item["price"]*$ses_quan);

?>
<tr>
			<td><a href="<?php echo "phpCart_manage.php?act=del&pid=".$ses_id; ?>">delete</a></td>
			<td><input name="newquan[]" type="text" id="newquan[]3" value="<?php echo $ses_quan; ?>" size="5" maxlength="4">
			<input name="eid[]" type="hidden" id="eid[]" value="<?php echo $ses_id; ?>"></td>
			<td><?php echo $item["title"]; ?></td>
			<td><?php echo $cur_symbol."".number_format($item["price"], 2, '.', ''); ?></td>
			<td><?php echo $cur_symbol."".number_format($subtotal, 2, '.', ''); ?></td>
			</tr>
<?php
} 

} elseif ($_SESSION["cart"] == NULL) {

echo "<td colspan=\"5\"><center><p>Your basket is currently empty.</p></center></td>";

} else {

echo "<td colspan=\"5\"><center><p>Unknown Error.</p></center></td>";

}
?>

 

Would anyone see what's possibly wrong?

 

Thank you,

ayok

Link to comment
https://forums.phpfreaks.com/topic/83507-solved-extra-rows/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.