Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.