okay, i think this will work properly as a shopping cart.. but i can think of one problem off the top of my head, the user would only be able to buy one type of product at a time, how can i fix this?
<?
$quantity = abs($quantity);
$cost = abs($_POST['cost']);
$totalcost = $cost * $quantity;
$dbuser = 'Blade';
$dbpass = '****';
//connect to the DB and select the database
$connection = mysql_connect('localhost', $dbuser, $dbpass)
or die(mysql_error());
mysql_select_db('cart', $connection) or die(mysql_error());
//set up the query
$query = "SELECT * FROM HN_cart
WHERE product='$product' and cost='$cost' and quantity='$quantity'";
//run the query and get the number of affected rows
$result = mysql_query($query, $connection) or die("error making query");
$affected_rows = mysql_num_rows($result);
if($affected_rows > 0){
setcookie("product", $product, time()+1800) or die("error");
setcookie("cost", $cost, time()+1800) or die("error");
setcookie("quantity", $quantity, time()+1800) or die("error");}
echo "
<table align=\"center\" cellspacing=\"0\" cellpadding=\"3\" border=\"1\" bordercolor=\"black\">
<tr>
<td><font size=\"-1\">Product</td>
<td><font size=\"-1\">Price</td>
<td><font size=\"-1\">Quantity</td>
<td><strong><font size=\"-1\">Total Price</strong></td>
</tr>
<tr>
<td>$product</td>
<td>$cost</td>
<td>$quantity</td>
<td>$totalcost</td>
</tr>
</table>
";
?>