I have a BIG problem, and I would apreciate any help anyone can provide. I have a variable value problem, I don't know why but I think the wrong value is being passed to the wrong variable.
This is for our extranet catalog, we have clothing products geared towards kids, and for each product i'm not displaying the right Age Group applicable for this particular clothing SKU.
Here is the relevant code:
Code: Select all
//This function searches the product table for products matching the given criteria.
function searchProducts(&$db,$ageId,$priceId,$pieceId,$awardWinner,$newProduct,$pageIndex,$Catnum,$numToDisplay) {
//Query the database for matching products
$prodQuery = productQuery($ageId,$priceId,$pieceId,$awardWinner,$newProduct,$pageIndex,$Catnum);
$prodQuery->doquery2($db);
$i=0;
$products = array();
while( $p = $prodQuery->getrow() ) {//Loop through the rows in the product table which matched the criteria.
$prod = createProduct($db, $p, $subCat ); //Creates a product from the given data.
$productsї$i++] = $prod; //put product into array.
}
return $products; //return the products found.
}Code: Select all
//Gets product information from other tables and returns a Product.
function createProduct(&$db,$prodRow) {
//data elements in the $prodRow
list($prodId,$newProd,$awardProd,$prodName,$prodThmImg,$prodPopUpImg,$prodSKU,$piecesId,$priceId,$ageId) = $prodRow;
//get the pieces
$pieceQuery = piecesQuery($piecesId);
$pieceQuery->doquery2($db);
list($prodPieces) = $pieceQuery->getrow();
//get the price
$priceQuery = priceQuery($priceId);
$priceQuery->doquery2($db);
list($prodPrice) = $priceQuery->getrow();
//get the age
$ageQuery = ageQuery($ageId);
$ageQuery->doquery2($db);
list($prodAge) = $ageQuery->getrow();
//return the Product
return array( $prodId,$prodName,$prodAge,$prodPieces,$prodPrice,$prodSKU,$prodThmImg,$prodPopUpImg,
$awardProd,$newProd,$ageId,$skillId,$piecesId,$priceId);
}Code: Select all
//Returns the query which gets the age name from the ages table
function ageQuery($ageId) {
$strSQL =
"SELECT
age.Nom AS prodAge
FROM
tableName age
WHERE
age.Age_Id='$ageId'";
$q = new Query();
$q->setSQL($strSQL);
return $q;
}For some reason, it seems that the value of $Catnum is being passed to $ageID.
Any help would be greatly apreciated.
Thx