adrian28uk Posted May 11, 2007 Share Posted May 11, 2007 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>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/50934-creating-a-small-shopping-cart-help-with-options/ Share on other sites More sharing options...
c_shelswell Posted May 11, 2007 Share Posted May 11, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/50934-creating-a-small-shopping-cart-help-with-options/#findComment-250597 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.