jay83r Posted November 13, 2012 Share Posted November 13, 2012 hey all, i have a tricky problem that i can't get my head around. i have a msql table that will populate a drop down menu, this is fine. I have another table that has a column that contains a number that i want to use to tell how many times the drop down menu should appear. for example. beach house has a drop down number of 8 (8 possible locations to place an option) - so when i display my php page showing this row (using GET) it shows 8 drop down menus from the table drop down menu (all menus are the same) eg. MENU: Window Sliding Door Entry Door i'm totally lost on how to get the 8 from the beach house row to relate to the number of drop down menus. Link to comment https://forums.phpfreaks.com/topic/270650-dynamically-create-multiple-drop-down-menus/ Share on other sites More sharing options...
Muddy_Funster Posted November 14, 2012 Share Posted November 14, 2012 without your current code theres nothing specific that can be given to you. a generic example would be along the lines of : $count = $_GET['numOfMenus']; $menuList = array(); $sql = "SELECT menuItems FROM menuTable WHERE targetValue = 'Beach House'"; $result = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)){ $menuList[] = $row['menuItems']; } for($i=0;$i<=$count;$i++){ echo "<select name=\"menu{$i}\" id=\"menu{$i}\">" foreach($menuList as $menuItem =>$menuValue){ echo "<option value=\"{$menuValue}\">{$menuValue}</option>"; } echo "</select>"; } Link to comment https://forums.phpfreaks.com/topic/270650-dynamically-create-multiple-drop-down-menus/#findComment-1392219 Share on other sites More sharing options...
jay83r Posted November 14, 2012 Author Share Posted November 14, 2012 Ahhhh thats exactly what i was looking for! it's much simpler than using JS to show/hide rows. Link to comment https://forums.phpfreaks.com/topic/270650-dynamically-create-multiple-drop-down-menus/#findComment-1392455 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.