Hi,
Ok, I figured out the first half my of question, but can't seem to figure the second problem.
I have a demo site that sells products. When I go to the detail page to view a product; if the product has an option, I have a query to pull those options out.
I have the options set up in a table and it matches based on the productID
Ok, what I have created is one script that loops through and selects the options for that specific product and then groups them and displays them in their own <select>.
Here is the code:
<?
$result = @("SELECT DISTINCT OptionName
FROM $table_op,$table_pro
WHERE OptionProductID = '$HTTP_GET_VARS[ProductID]'");
while ($row = @mysql_fetch_array($result)) {
echo "<SELECT NAME='OPTION|1|$HTTP_GET_VARS[ProductID]'>";
echo "<option value=\"invalid\">--Select $row[OptionName]--</option>\n";
$result2 = @("SELECT ProductID, OptionProductID, OptionName, OptionValue, OptionCost
FROM $table_pro LEFT JOIN $table_op ON Options.OptionProductID = Products.ProductID
WHERE OptionProductID = '$HTTP_GET_VARS[ProductID]' AND OptionName = '$row[OptionName]'
");
while ($row2 = @mysql_fetch_array($result2)) {
echo "<option value='$row2[OptionName]: $row2[OptionValue]|$row2[OptionCost]|0'>$row2[OptionValue] \$$row2[OptionCost]</option>\n";
}
echo "</SELECT><br><br>";
}
?>
It all works just fine, but the next step I have to do is now everytime it loops through and displays a new <select> field I have to have the 1 increase, so if there are 3 different options size,weight,color then each <select> would have to look like this:
NAME='OPTION|1|
NAME='OPTION|2|
NAME='OPTION|3|
"<SELECT NAME='OPTION|1|$HTTP_GET_VARS[ProductID]'>
I have tried doing various things, but don't get the results I want. I want to know if anyone has any suggestions.
thanks,
I will continue working on this.
Brett