jboy6t9 Posted January 8, 2007 Share Posted January 8, 2007 hello. i would love some help or someone to point me in the right direction.I am building an ecommerce wesite selling clothes. i want to know if the following is possible.For example, i have a product T-Shirt, that is available in RED,BLACK,BROWN and is availalbe in 4 sizes. Small, Medium, Large, X-Large.I store it in the database using 4 fields, ID(1), ProductName (T-Shirt), Colors(RED,BLACK,BROWN), Sizes(Small, Medium, Large, X-Large), Price (12.00)so now i create a PHP page that displays the product details. THIS IS WHERE I NEED THE HELP[b]I want to take the COLORS and SIZES and create drop down menu's with the data in the fields in the order they are typed.[/b]can this be done? any ideas? thanks in advance. Link to comment https://forums.phpfreaks.com/topic/33310-display-comma-separated-value-from-database-in-a-drop-down-menu/ Share on other sites More sharing options...
kam_uoc Posted January 8, 2007 Share Posted January 8, 2007 this may be help you. this create a combo. apply your option an send it to database as text.<form name="form1" method="post" action=""> <select name="select"> <option>abc</option> <option>xyz</option> </select></form> Link to comment https://forums.phpfreaks.com/topic/33310-display-comma-separated-value-from-database-in-a-drop-down-menu/#findComment-155660 Share on other sites More sharing options...
.josh Posted January 8, 2007 Share Posted January 8, 2007 example of how to dynamically build a drop down, using your comma seperated string:[code]<?php $sql = "select * from table"; $result = mysql_query($sql) or die(mysql_error()); while ($list = mysql_fetch_assoc($result)) { echo "<select name = 'color'>"; $colors = explode(',',$list['Colors']); foreach($colors as $c) { echo "<option value='$c'>$c</option>"; } // end foreach color echo "</select>"; } // end while ?>[/code] Link to comment https://forums.phpfreaks.com/topic/33310-display-comma-separated-value-from-database-in-a-drop-down-menu/#findComment-155663 Share on other sites More sharing options...
jboy6t9 Posted January 8, 2007 Author Share Posted January 8, 2007 thank you for your answer.. i will try that out.much appriciated! Link to comment https://forums.phpfreaks.com/topic/33310-display-comma-separated-value-from-database-in-a-drop-down-menu/#findComment-155909 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.