Thanks so much! eCart had automatically inserted the code after the rsSizes recordset that was in the loop.
The add to cart button works now except that the values for the weight, size and price are all 0. Are my recordsets the problem, or is there something else that I'm missing?
Here's the revised code:
<?php
//WA eCart Include
require_once("WA_eCart/CarteBlank_PHP.php");
?>
<?php require_once('Connections/connSpectrum.php'); ?>
<?php
$CarteBlank->GetContent();
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_connSpectrum, $connSpectrum);
$query_rsItems = "SELECT ItemID, ItemCatID, ItemName, ItemDesc, ItemSKU, ItemImage FROM items ORDER BY ItemID ASC";
$rsItems = mysql_query($query_rsItems, $connSpectrum) or die(mysql_error());
$row_rsItems = mysql_fetch_assoc($rsItems);
$totalRows_rsItems = mysql_num_rows($rsItems);
$paramOption_rsSizeLookup = "-1";
if (isset($_POST['eCarteBlank_1_size_Add'])) {
$paramOption_rsSizeLookup = $_POST['eCarteBlank_1_size_Add'];
}
$paramItem_rsSizeLookup = "-1";
if (isset($_POST['eCarteBlank_1_ID_Add'])) {
$paramItem_rsSizeLookup = $_POST['eCarteBlank_1_ID_Add'];
}
mysql_select_db($database_connSpectrum, $connSpectrum);
$query_rsSizeLookup = sprintf("SELECT options.OptionID, options.`Option`, options.OptionPrice, options.OptionWeight, itemoptions.ItemOptionID FROM options INNER JOIN itemoptions ON options.OptionID = itemoptions.OptionID WHERE itemoptions.OptionID = %s AND itemoptions.OptionID = %s", GetSQLValueString($paramOption_rsSizeLookup, "int"),GetSQLValueString($paramItem_rsSizeLookup, "int"));
$rsSizeLookup = mysql_query($query_rsSizeLookup, $connSpectrum) or die(mysql_error());
$row_rsSizeLookup = mysql_fetch_assoc($rsSizeLookup);
$totalRows_rsSizeLookup = mysql_num_rows($rsSizeLookup);
?>
<?php
// WA eCart AddToCart
if (isset($_POST["CarteBlank_1_ATC"]) || isset($_POST["CarteBlank_1_ATC_x"])) {
$ATC_itemID = $_POST["CarteBlank_1_ID_Add"];
$ATC_AddIfIn = 0;
$ATC_RedirectAfter = "cart.php";
$ATC_RedirectIfIn = "";
if (isset($totalRows_rsItems) && $totalRows_rsItems > 0) {
$row_rsItems = WAEC_findRecordMySQL($rsItems, "ItemID", $ATC_itemID);
if ($row_rsItems) {
$ATC_itemName = "".$row_rsItems['ItemName'] ."";// column binding
$ATC_itemDescription = "".$row_rsItems['ItemDesc'] ."";// column binding
$ATC_itemThumbnail = "img/small/".$row_rsItems['ItemImage'] ."";// column binding
$ATC_itemWeight = floatval("".$row_rsSizeLookup['OptionWeight'] ."");// column binding
$ATC_itemQuantity = "".$_POST["CarteBlank_1_Quantity_Add"] ."";// column binding
$ATC_itemPrice = floatval("".$row_rsSizeLookup['OptionPrice'] ."");// column binding
$ATC_itemSize = "".$row_rsSizeLookup['Option'] ."";// column binding
$ATC_itemSKU = "".$row_rsItems['ItemSKU'] ."";// column binding
mysql_data_seek($rsItems, 0);
$row_rsItems = mysql_fetch_assoc($rsItems);
}
}
$ATC_itemQuantity = floatval($ATC_itemQuantity);
if (is_numeric($ATC_itemQuantity) && $ATC_itemQuantity != 0) {
$CarteBlank->AddToCart($ATC_AddIfIn, $ATC_RedirectIfIn, $ATC_itemID, $ATC_itemName, $ATC_itemDescription, $ATC_itemThumbnail, $ATC_itemWeight, $ATC_itemQuantity, $ATC_itemPrice, $ATC_itemSize, $ATC_itemSKU);
if ($ATC_RedirectAfter != "" && $CarteBlank->redirStr == "") {
$CarteBlank->redirStr = $ATC_RedirectAfter;
}
if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != "") {
$_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
}
else {
$_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF'];
}
}
}
?>
<?php
// WA eCart Redirect
if ($CarteBlank->redirStr != "") {
header("Location: ".$CarteBlank->redirStr);
}
?>
<!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=utf-8" />
<title>Product Page</title>
<link href="css/global.css" rel="stylesheet" type="text/css" />
</head>
<body background="img/metgrad.jpg">
<div id="container">
<div id="banner">
<p><img src="img/header2.gif" alt="" width="950" height="141" longdesc="http://www.fff.com/" /></p>
</div>
<?php do { ?>
<?php
$varItem_rsSizes = "1";
if (isset($row_rsItems['ItemID'])) {
$varItem_rsSizes = $row_rsItems['ItemID'];
}
mysql_select_db($database_connSpectrum, $connSpectrum);
$query_rsSizes = sprintf("SELECT items.ItemID, options.OptionID, options.Option, options.OptionPrice, options.OptionWeight FROM items LEFT OUTER JOIN itemoptions ON items.ItemID = itemoptions.ItemID INNER JOIN options ON itemoptions.OptionID = options.OptionID WHERE items.ItemID = %s", GetSQLValueString($varItem_rsSizes, "int"));
$rsSizes = mysql_query($query_rsSizes, $connSpectrum) or die(mysql_error());
$row_rsSizes = mysql_fetch_assoc($rsSizes);
$totalRows_rsSizes = mysql_num_rows($rsSizes);
?>
<div class="ul">
<p><?php echo $row_rsItems['ItemName']; ?></p>
<p><?php echo $row_rsItems['ItemDesc']; ?></p>
<p><?php echo $row_rsItems['ItemSKU']; ?></p>
<p><img src="img/small/<?php echo $row_rsItems['ItemImage']; ?>" alt="image" /></p>
<p> <form name="CarteBlank_1_ATC_<?php echo $row_rsItems["ItemID"]; ?>" method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?><?php echo (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "")?"?".$_SERVER["QUERY_STRING"]:""; ?>">
<p>
<input type="hidden" name="CarteBlank_1_ID_Add" value="<?php echo $row_rsItems["ItemID"]; ?>" >
<input type="text" name="CarteBlank_1_Quantity_Add" value="1" size="4" >
<label for="eCarteBlank_1_size_Add">Sizes & Prices</label>
<select name="eCarteBlank_1_size_Add" id="eCarteBlank_1_size_Add">
<?php
do {
?>
<option value="<?php echo $row_rsSizes['ItemID']?>"><?php echo $row_rsSizes['Option']?> $<?php echo $row_rsSizes['OptionPrice']?></option>
<?php
} while ($row_rsSizes = mysql_fetch_assoc($rsSizes));
$rows = mysql_num_rows($rsSizes);
if($rows > 0) {
mysql_data_seek($rsSizes, 0);
$row_rsSizes = mysql_fetch_assoc($rsSizes);
}
?>
</select>
</p>
<p>
<input type="image" src="img/PNG/addtocart.png" border="0" class="eC_ImageButton" value="Add to Cart" name="CarteBlank_1_ATC">
</p>
</form>
</p>
<p> </p>
</div>
<!-- An associative fetch array-which returns one row of date
at a time, in an array format -->
<?php } while ($row_rsItems = mysql_fetch_assoc($rsItems)); ?>
</div>
</body>
</html>
<?php
mysql_free_result($rsItems);
mysql_free_result($rsSizes);
mysql_free_result($rsSizeLookup);
?>
Thanks much, I'm grateful for your help.