Skip to main content
Known Participant
September 5, 2006
Question

Total - its urgent

  • September 5, 2006
  • 4 replies
  • 373 views
I am unable to multiply the price of each item with quantity stored and display it on the cart page......please help with this its urgent. Thanks in advance.
This topic has been closed for replies.

4 replies

prashi123Author
Known Participant
September 6, 2006
show cart code is as follows


<?php require_once('Connections/prashi.php'); ?>
<?php
$maxRows_cart = 10;
$pageNum_cart = 0;
if (isset($_GET['pageNum_cart'])) {
$pageNum_cart = $_GET['pageNum_cart'];
}
$startRow_cart = $pageNum_cart * $maxRows_cart;

$colname_cart = "-1";
if (isset($_GET['userid'])) {
$colname_cart = (get_magic_quotes_gpc()) ? $_GET['userid'] : addslashes($_GET['userid']);
}
mysql_select_db($database_prashi, $prashi);
$query_cart = sprintf("SELECT * FROM cart WHERE user_id = %s", $colname_cart);
$query_limit_cart = sprintf("%s LIMIT %d, %d", $query_cart, $startRow_cart, $maxRows_cart);
$cart = mysql_query($query_limit_cart, $prashi) or die(mysql_error());
$row_cart = mysql_fetch_assoc($cart);

if (isset($_GET['totalRows_cart'])) {
$totalRows_cart = $_GET['totalRows_cart'];
} else {
$all_cart = mysql_query($query_cart);
$totalRows_cart = mysql_num_rows($all_cart);
}
$totalPages_cart = ceil($totalRows_cart/$maxRows_cart)-1;
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<table border="1" cellpadding="2" cellspacing="5">
<tr>
<td>cartId</td>
<td>cookieId</td>
<td>pro_id</td>
<td>qty</td>
<td>user_id</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_cart['cartId']; ?></td>
<td><?php echo $row_cart['cookieId']; ?></td>
<td><?php echo $row_cart['pro_id']; ?></td>
<td><?php echo $row_cart['qty']; ?></td>
<td><?php echo $row_cart['user_id']; ?></td>
</tr>
<?php } while ($row_cart = mysql_fetch_assoc($cart)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($cart);
?>



this code as ability to store the product id but when the user adds the same product twice the quantity is not upadated instead a new row of same product id is created with increment in cart_id and i have no idea how to add a total, subtotal into it......please help with this
Inspiring
September 5, 2006
>I know the operator but i need the syntax or code in php for doing it......

What does your current PHP code look like?

--
Regards

John Waller


prashi123Author
Known Participant
September 5, 2006
I know the operator but i need the syntax or code in php for doing it......
Inspiring
September 5, 2006
In most languages, the operator used to multiply variables is *. eg

LineTotal=Price*Quantity

--
Jules
http://www.charon.co.uk/charoncart
Charon Cart 3
Shopping Cart Extension for Dreamweaver MX/MX 2004