Jump to content

Creating a small shopping cart help with options


adrian28uk

Recommended Posts

I am creating a small shopping cart for educational purposes now I have some time on my hands.

I have created my products table, cart table and a table that will allow me to create product options for each product and will appear in select menus when the product is selected.

 

What my small script does below is display a select menu if the product has options for example one product might have options, that allow you select the size in the first select menu and colour in the second select menu.

 

I have managed to display two drop downs for one of my products but I cannot get the </select> to end after the first drop down menu is created. Wondering if you could help and show me where I might be going wrong.

 

$query = "SELECT product_option_name, product_option_number FROM products_options WHERE product_id=1";

$result = mysql_query($query);

 

while ($row = mysql_fetch_array($result)) {

    if ($row['product_option_number'] != $product_option_number) {

      $product_option_number = $row['product_option_number'];

 

    echo "<select name=". $product_option_number .">";

 

}

echo "<option value=" . $row['product_option_name']. ">". $row['product_option_name']. "</option>";

}

 

echo"</select>";

?>

it looks a lot like you might be ending up with or at least there's the possibility that you're echoing too many <select>'s to start with. You should check the html output source from your browser and see what you're actually making with the loop you have.

 

Hope this helps

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.