i have a cart with multiple items that has a numeric input field and would like to update the dB according to that field, this is what i have so far.
my problem is how do i update the cart with that input field and write into the dB?
PHP Code:
$id = $_GET['id'];
$queryX = "SELECT * FROM trackcarts INNER JOIN products ON products.productID = trackcarts.productID WHERE sessionID='$cartid' AND deleted ='0'";
$resultX = mysql_query($queryX) or die (mysql_error());
<?
$count = 0;
while ($rowX = mysql_fetch_array($resultX)) {
echo "<tr>\n";
echo "<td height='60' width='80' style='padding-bottom:30px;'>\n<a href='product.php?id=";
print_r ($rowX['productID']);
echo"&view=A '><img class='barImg' src='assets/main_small/A_";
print_r ($rowX['productID']);
echo ".jpg' width='50' height='50' /></a>\n</td>\n";
echo "<td valign='bottom' width='200' style='padding-bottom:30px;' '>\n";
echo"<ul class='cartDescription'>\n<li class='cartDescript1'>";
print_r ($rowX['itemName']);
echo "</li>\n<li class='cartDescript2'>";
$str6 = ($rowX['productID']);
echo substr($str6, 0, 6);
echo"</li>\n</ul>\n";
echo "</td>\n";
echo "<td valign='bottom' width='200' style='padding-bottom:30px;' '>\n";
echo"<ul class='cartDescription'>\n<li class='cartDescript1'>";
print_r ($rowX['fabricName']);
echo "</li>\n<li class='cartDescript2'>";
$str3 = ($rowX['productID']);
$three = substr($str3, 0, 3);
if ($three == "VOY") {
$str3 = ($rowX['productID']);
echo substr($str3, -3);
}else {
$str3 = ($rowX['productID']);
echo substr($str3, -2);
}
echo"</li>\n</ul>\n";
echo "</td>\n";
echo "<td valign='bottom' width='100' style='padding-bottom:30px;' '>\n";
//print_r ($rowX['qty']);
echo "<form><input type='text' name='qty' size= '5' value='";
$qty = ($rowX['qty']);
echo $qty;
echo "' /></form>";
echo "</td>\n";
echo "<td valign='bottom' width='120' style='padding-bottom:30px;' '>\n";
$price = ($rowX['price']);
echo $price/2;
echo "</td>\n";
echo "<td align='left' valign='bottom' width='120' style='padding-bottom:30px;'><a class='itemNum' href='cartRemove.php?id=";
print_r ($rowX['productID']);
echo "'>remove</a></td>\n";
echo "<td align='right' valign='bottom' width='120' style='padding-bottom:30px;' width='50'>";
echo "<a href='cartupdate.php?id="; //////<<<<< code below
print_r ($rowX['productID']);
echo "&qty=";
echo $_GET["qty"];
echo"'>update cart</a>";
echo "</td>\n</tr>\n";
$count++;
}
echo"</table>";
?>
then cartupdate.php lookslike this. i will have multiple items so i know that the variable $qty will prob. not work
PHP Code:
<?php
session_start();
if (!empty($cartid)) {
$cartid = $_SESSION['cartid'];
} else {
$cartid = session_id();
$_SESSION['cartid'] = $cartid;
$visitor = $_SERVER[REMOTE_ADDR];
}
include("dbconnect.php");
$id = $_GET['id'];
$qty = $_GET['qty'];
$queryD = "UPDATE trackcarts SET qty = $qty WHERE sessionID = '$cartid' AND productID='$id'";
$resultD = mysql_query($queryD) or die (mysql_error());
include("cart.php");
exit();
?>
Bookmarks