Handling "related items" -
07-13-2003
, 02:46 PM
Hello -- I want to build a product page that has a section for "related items". Right now my product database has a column for "related items" in which I have put the product ID number for a related item.
I can pull up the product page recordset based on one product ID number easy enough. I'm having trouble pulling up a second recordset for the related item based on that second ID number which is found in a column of the first. Any idea how I could do this? Here's my current script (copied out of Dreamweaver . . . I am a newbie), but it keeps giving me an error. Thanks.
<?php require_once('Connections/Duke.php'); ?>
<?php require_once('Connections/Duke.php'); ?>
<?php
$colname_rsProductPage = "1";
if (isset($HTTP_GET_VARS['PROD_NUM'])) {
$colname_rsProductPage = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['PROD_NUM'] : addslashes($HTTP_GET_VARS['PROD_NUM']);
}
mysql_select_db($database_Duke, $Duke);
$query_rsProductPage = sprintf("SELECT PROD_NUM, MANU_NAME, PROD_FAMILY, PROD_NAME, UNIQUE_NAME, CATEGORY_1, CATEGORY_2, PRICE, DESCRIPTION, DESIGNER, DIMENSIONS, MATERIAL, IMAGE_600, IMAGE_250, IMAGE_050, COLOR_PALETTE, RELATED_1, RELATED_2, RELATED_3, RELATED_4, LOCATION_1, LOCATION_2, LOCATION_3, LOCATION_4 FROM TSIMproducts WHERE PROD_NUM = %s", $colname_rsProductPage);
$rsProductPage = mysql_query($query_rsProductPage, $Duke) or die(mysql_error());
$row_rsProductPage = mysql_fetch_assoc($rsProductPage);
$totalRows_rsProductPage = mysql_num_rows($rsProductPage);
mysql_select_db($database_Duke, $Duke);
$query_rsVariants = "SELECT UNIQUE_NAME FROM TSIMproducts WHERE PROD_NAME =".$row_rsProductPage['PROD_NAME'];
$rsVariants = mysql_query($query_rsVariants, $Duke) or die(mysql_error());
$row_rsVariants = mysql_fetch_assoc($rsVariants);
$totalRows_rsVariants = mysql_num_rows($rsVariants); |