Zergman Posted November 22, 2008 Share Posted November 22, 2008 Just curious if its possible to have a dynamic dropdown menu but also include a non-dynamic menu item in the same dropdown .... hopefully I worded that right Link to comment https://forums.phpfreaks.com/topic/133836-solved-dynamic-drop-menu-question/ Share on other sites More sharing options...
dezkit Posted November 22, 2008 Share Posted November 22, 2008 How those this relate to php? Link to comment https://forums.phpfreaks.com/topic/133836-solved-dynamic-drop-menu-question/#findComment-696576 Share on other sites More sharing options...
samona Posted November 22, 2008 Share Posted November 22, 2008 Yes it's possible. Link to comment https://forums.phpfreaks.com/topic/133836-solved-dynamic-drop-menu-question/#findComment-696577 Share on other sites More sharing options...
Zergman Posted November 22, 2008 Author Share Posted November 22, 2008 @dezkit - Wasn't sure if this was the right section but I do pull my menu via php @samona - Cool, time to hit google! Link to comment https://forums.phpfreaks.com/topic/133836-solved-dynamic-drop-menu-question/#findComment-696581 Share on other sites More sharing options...
aeonsky Posted November 22, 2008 Share Posted November 22, 2008 Does this answer your question? <?PHP $menu_array = array("Home", "Forums", "Media"); print "<select name=\"main\">"; for($i=0; $i < count($menu_array); $i++) print "<option>$menu_array[$i]</option>"; print "</select>"; ?> Link to comment https://forums.phpfreaks.com/topic/133836-solved-dynamic-drop-menu-question/#findComment-696587 Share on other sites More sharing options...
Zergman Posted November 22, 2008 Author Share Posted November 22, 2008 Thanks aeonsky, I sorta can see from your example, but trying to adapt it to my select box is causing a few issues. Here's what I got so far, unsure how to add one value to the top of the dropdown before the dynamic stuff. <select name="tracking" class="inputbox" id="tracking"> <?php do { ?> <option value="<?php echo $row_rsmenufield['value']?>"><?php echo $row_rsmenufield['value']?></option> <?php } while ($row_rsmenufield = mysql_fetch_assoc($rsmenufield)); $rows = mysql_num_rows($rsmenufield); if($rows > 0) { mysql_data_seek($rsmenufield, 0); $row_rsmenufield = mysql_fetch_assoc($rsmenufield); } ?> </select> Please pardon my sloppy code Link to comment https://forums.phpfreaks.com/topic/133836-solved-dynamic-drop-menu-question/#findComment-696590 Share on other sites More sharing options...
Zergman Posted November 23, 2008 Author Share Posted November 23, 2008 Cool, figured it out. I know this isn't the best solution but it works for now. <select name="tracking" class="inputbox" id="tracking"> <option value="n/a">n/a</option> <?php do { ?> <option value="<?php echo $row_rsmenufield['value']?>"><?php echo $row_rsmenufield['value']?></option> <?php } while ($row_rsmenufield = mysql_fetch_assoc($rsmenufield)); $rows = mysql_num_rows($rsmenufield); if($rows > 0) { mysql_data_seek($rsmenufield, 0); $row_rsmenufield = mysql_fetch_assoc($rsmenufield); } ?> </select> Link to comment https://forums.phpfreaks.com/topic/133836-solved-dynamic-drop-menu-question/#findComment-696595 Share on other sites More sharing options...
samona Posted November 23, 2008 Share Posted November 23, 2008 How about right before the <?php tag? Just add another <option value="">Example</> Link to comment https://forums.phpfreaks.com/topic/133836-solved-dynamic-drop-menu-question/#findComment-696596 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.