Jump to content

[SOLVED] Extra Rows


ayok

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

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.