Hi, I am trying to use this script:
http://www.phpbuilder.com/columns/jason_gilmore20080502_2.php3?aid=1456
I got it working just fine, however I am having some trouble with getting the price from my database (mysql), maybe you can help, used several days fixing it .. driving me crazy ..
Here is my code, now what i want to do, is to take the ID from my product, get the price for "each" from my database, and then getting the sum of that, like so:
id amount price(one) price
1 3 100 300
2 2 200 400
700 (this is what i am missing)
<?include_once 'includes/connection.php';?>
<?php
include("cart.class.php");
session_start();
?>
<? $items = $_SESSION["cart"];
print_r($_SESSION["cart"]);?><p>
<? echo "Sum of values = ".array_sum($items);
?><p>
<?
$str =
reset($items);
while (list($key, $val) = each(&$items))
{?><?
//LOOP START?>
<?$result = mysql_query("SELECT * FROM product where id = '$key' ");
while ($record = mysql_fetch_object($result)) {?>
<?$price1 = $record->price;
$discount1 = $record->discount;
$price = $price1 - $discount1;
$price2 = $price * $val;
echo "$price,";}?>
<?$str = $price;?>
<?//LOOP END ?>
<?}?><p>
<?echo "$str";?><p>
<?
echo "Sum of values = ".array_sum($list);
print_r(explode(" , ", $items));
?>
THANK YOU FOR LOOKING 🙂