php mySQL filtering problem...really desperate
Hi
I have a live site that is currently causing me some issues
It is a fashion site that sends the product information that is pulled in from sevaral table to the checkout.. the issue i am having is the incorrect stock id is being sent to the checkout so when it returns from the gateway it is updating the wrong stock levels.
What is happening currently is the stockID from the first size is being sent.
what i have is the following tables
table 1 - beauSS13_products
ProductID
CatID
table 2 - beauSS13_Cat
catID
table3 - beauSS13_Stock
StockID
ID (this was named like this incorrectly) but this joins with ProductID
SizeID
Stock
beauSS13_SizeList
SizeID
Size
the SQL is
$var1_rsProduct = "-1";
if (isset($_GET['ProductID'])) {
$var1_rsProduct = $_GET['ProductID'];
}
mysql_select_db($database_beau, $beau);
$query_rsProduct = sprintf("SELECT * FROM beauSS13_Cat, beauSS13_products, beauSS13_Stock, beauSS13_SizeList WHERE beauSS13_products.CatID = beauSS13_Cat.catID AND beauSS13_products.ProductID = beauSS13_Stock.ID AND beauSS13_Stock.SizeID = beauSS13_SizeList.SizeID AND beauSS13_products.ProductID = %s AND beauSS13_Stock.Stock != 0 ", GetSQLValueString($var1_rsProduct, "int"));
i think beauSS13_products.ProductID = beauSS13_Stock.ID shouldnt be there ( but am not sure what it should have )
I need to identify the Unique Stock ID from table3 - beauSS13_Stock
basically cant get my head round the logic...
if i remove beauSS13_products.ProductID = beauSS13_Stock.ID
then in the
select list
<select name="SelectSize" id="SelectSize">
<option value="Select Size">Select Size</option>
<?php
do {
?>
<option value="<?php echo $row_rsProduct['Size']?>"><?php echo $row_rsProduct['Size']?></option>
<?php
} while ($row_rsProduct = mysql_fetch_assoc($rsProduct));
$rows = mysql_num_rows($rsProduct);
if($rows > 0) {
mysql_data_seek($rsProduct, 0);
$row_rsProduct = mysql_fetch_assoc($rsProduct);
}
?>
</select>
it outputs all sizes from the ProductID and not just from the selected item
i have just tried
<select name="SelectSize" id="SelectSize">
<option value="Select Size">Select Size</option>
<?php
do {
?>
<option value="<?php echo $row_rsProduct['Size']?>"><?php echo $row_rsProduct['Size']?><?php echo $row_rsProduct['StockID']; ?></option>
<?php
} while ($row_rsProduct = mysql_fetch_assoc($rsProduct));
$rows = mysql_num_rows($rsProduct);
if($rows > 0) {
mysql_data_seek($rsProduct, 0);
$row_rsProduct = mysql_fetch_assoc($rsProduct);
}
?>
</select>
and adding <?php echo $row_rsProduct['StockID']; ?>
i can see the correct StockID is showing in the size menu but i just need to get that to send to cart
this is the code that sends the details to the cart
$XC_editAction1 = $_SERVER["PHP_SELF"];
if (isset($_SERVER["QUERY_STRING"])) $XC_editAction1 = $XC_editAction1 . "?" . $_SERVER["QUERY_STRING"];
if (isset($_POST["XC_addToCart"]) && $_POST["XC_addToCart"] == "form1") {
$NewRS=mysql_query($query_rsProduct, $beau) or die(mysql_error());
$XC_rsName="rsProduct"; // identification
$XC_uniqueCol="ProductID";
$XC_redirectTo = "";
$XC_redirectPage = "../cart.php";
$XC_BindingTypes=array("RS","RS","FORM","FORM","RS","RS","RS","NONE");
$XC_BindingValues=array("StockID","ProductID","SelectSize","Quantity","Product","Price","Stock","");
$XC_BindingLimits=array("","","","","","","","");
$XC_BindingSources=array("","","","","","","","");
$XC_BindingOpers=array("","","","","","","","");
require_once('XCInc/AddToXCartViaForm.inc');
}