I have redone my tables and they match the ecommerce recipe example, which was not very clear or helpful, exactly. (By the way, in their example they use the run time value of $run_rsfrozen['itemid'].) I have tried your method. I put the $_GET['tempitemid'] in the runtime value. I then put the other php code in every possible place at the top of the page. It makes no difference. Every item still shows every possible option intstead of the options that are set for it. Here is the code. What do you think?
<?php
//WA eCart Include
require_once("WA_eCart/ayscart_PHP.php");
?><?php require_once('Connections/aysconn.php'); ?>
<?php
$ayscart->GetContent();
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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_aysconn, $aysconn);
$query_rsfrozen = "SELECT * FROM items WHERE itemcatid = '9'";
$rsfrozen = mysql_query($query_rsfrozen, $aysconn) or die(mysql_error());
$row_rsfrozen = mysql_fetch_assoc($rsfrozen);
$totalRows_rsfrozen = mysql_num_rows($rsfrozen);
$param_rsfoptions = "0";
if (isset($_GET['tempitemid'] )) {
$param_rsfoptions = (get_magic_quotes_gpc()) ? $_GET['tempitemid'] : addslashes($_GET['tempitemid'] );
}
mysql_select_db($database_aysconn, $aysconn);
$query_rsfoptions = sprintf("SELECT * FROM itemopt INNER JOIN options on options.itemoptid=itemopt.itemoption WHERE itemitemid=%s", GetSQLValueString($param_rsfoptions, "int"));
$rsfoptions = mysql_query($query_rsfoptions, $aysconn) or die(mysql_error());
$row_rsfoptions = mysql_fetch_assoc($rsfoptions);
$totalRows_rsfoptions = mysql_num_rows($rsfoptions);
?>
<?php
// WA eCart AddToCart
if (isset($_POST["ayscart_1_ATC"]) || isset($_POST["ayscart_1_ATC_x"])) {
$ATC_itemID = $_POST["ayscart_1_ID_Add"];
$ATC_AddIfIn = 0;
$ATC_RedirectAfter = "cart.php";
$ATC_RedirectIfIn = "";
if (isset($totalRows_rsfrozen) && $totalRows_rsfrozen > 0) {
$row_rsfrozen = WAEC_findRecordMySQL($rsfrozen, "itemid", $ATC_itemID);
if ($row_rsfrozen) {
$ATC_itemName = "".$row_rsfrozen['itemname'] ."";// column binding
$ATC_itemDescription = "".$row_rsfrozen['itemshortdesc'] ."";// column binding
$ATC_itemWeight = floatval("0");// column binding
$ATC_itemQuantity = "".$_POST["ayscart_1_Quantity_Add"] ."";// column binding
$ATC_itemPrice = floatval("".$row_rsfrozen['itemprice'] ."");// column binding
$ATC_itemOption = "".$_POST["ayscart_1_Option_Add"] ."";// column binding
mysql_data_seek($rsfrozen, 0);
$row_rsfrozen = mysql_fetch_assoc($rsfrozen);
}
}
$ATC_itemQuantity = floatval($ATC_itemQuantity);
if (is_numeric($ATC_itemQuantity) && $ATC_itemQuantity != 0) {
$ayscart->AddToCart($ATC_AddIfIn, $ATC_RedirectIfIn, $ATC_itemID, $ATC_itemName, $ATC_itemDescription, $ATC_itemWeight, $ATC_itemQuantity, $ATC_itemPrice, $ATC_itemOption);
if ($ATC_RedirectAfter != "" && $ayscart->redirStr == "") {
$ayscart->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 ($ayscart->redirStr != "") {
header("Location: ".$ayscart->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"><!-- InstanceBegin template="/Templates/cattemp.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Frozen Foods</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<link href="cartcss/tempcss.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
<div id="header"><img src="Images/header.gif" /></div>
<div id="content">
<div id="CatSideBar"></div>
<div id="MBody"><!-- InstanceBeginEditable name="mbody" -->Please select your favorite frozen items to keep you cool during your stay.<p><table width="672" height="53" border="1">
<?php do { ?>
<tr>
<td width="205"><?php echo $row_rsfrozen['itemname']; ?></td>
<td width="100"><select name="ayscart_Option_list_<?php echo $ayscart->DisplayIndex; ?>" >
<?php
do {
?>
<option value="<?php echo $row_rsfoptions['optname']?>"><?php echo $row_rsfoptions['optname']?></option>
<?php
} while ($row_rsfoptions = mysql_fetch_assoc($rsfoptions));
$rows = mysql_num_rows($rsfoptions);
if($rows > 0) {
mysql_data_seek($rsfoptions, 0);
$row_rsfoptions = mysql_fetch_assoc($rsfoptions);
}
?>
</select></td>
<td width="150"><?php echo $row_rsfrozen['itemshortdesc']; ?></td>
<td width="189"><?php echo $row_rsfrozen['itemprice']; ?></td>
<td width="100"><form name="ayscart_1_ATC_<?php echo $row_rsfrozen["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="ayscart_1_ID_Add" value="<?php echo $row_rsfrozen["itemid"]; ?>" >
<input type="text" name="ayscart_1_Quantity_Add" value="1" size="4" >
<select name="ayscart_1_Option_Add">
<?php
do {
?>
<option value="<?php echo $row_rsfoptions['optname']?>"><?php echo $row_rsfoptions['optname']?></option>
<?php
} while ($row_rsfoptions = mysql_fetch_assoc($rsfoptions));
$rows = mysql_num_rows($rsfoptions);
if($rows > 0) {
mysql_data_seek($rsfoptions, 0);
$row_rsfoptions = mysql_fetch_assoc($rsfoptions);
}
?>
</select>
<input type="image" src="WA_eCart/Images/Pacifica/Btn5_EN_addtocart.gif" border="0" value="Add to Cart" name="ayscart_1_ATC">
</p>
</form>
</td>
</tr>
<?php } while ($row_rsfrozen = mysql_fetch_assoc($rsfrozen)); ?>
</table>
</p><!-- InstanceEndEditable --></div>
</div>
<div id="footer"><img src="Images/footer-1.gif" /></div>
</div>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($rsfrozen);
mysql_free_result($rsfoptions);
?>