Yamaha32088 Posted February 27, 2008 Share Posted February 27, 2008 ME=Total newbie to php. This should be simple for most of you. Basically this is what I want. I want to create a dynamic drop down menu all of the dynamic content would be coming from a MySQL database. I need help with the coding and possibly the setup of the database. I want to create a main category after the user clicks what they want to look at another dynamic drop down menu would appear underneath it with sub categorys. Example = FOOD(Main)>FRUIT(the rest would be sub cats)>APPLES>JOHNNY APPLESEED>GREEN. something similar to that I hope that I have been clear enough Link to comment https://forums.phpfreaks.com/topic/93265-dynamic-list/ Share on other sites More sharing options...
bpops Posted February 27, 2008 Share Posted February 27, 2008 I don't think you'll find much help here just asking people to write code for you. What you need is atleast a basic understanding of mysql commands, php commands, and a bit of javascript to accomplish what you want. It's not hard, but you should Google some mysql and php tutorials to get you started. You'll appreciate the work you put into it, anyway, as it will help you in the future. If you have specific questions, come back here and ask. Link to comment https://forums.phpfreaks.com/topic/93265-dynamic-list/#findComment-477706 Share on other sites More sharing options...
DarkerAngel Posted February 27, 2008 Share Posted February 27, 2008 <?php echo("<select name=\"selection_name\">\n"); while($mysql_row = mysql_fetch_array($mysql_query) { echo("<option value=\"".$mysql_row['value']."\">".$mysql_row['lable']."</option>\n"); } echo("</select>"); ?> You could always replace echo, with a $string .= if you want it to store in a string before output. be sure to change the $mysql_row[fields] to the proper fields for you SQL table Link to comment https://forums.phpfreaks.com/topic/93265-dynamic-list/#findComment-477713 Share on other sites More sharing options...
cyrixware Posted February 27, 2008 Share Posted February 27, 2008 <?php $sql = "SELECT * FROM table ORDER BY field"; if(!$q = mysql_query($sql)) { //statements } elseif(!mysql_num_rows($q)) { //statements } else { ?> <select name="select"> <?php while($r_section = mysql_fetch_assoc($q)){ ?> <option value="<?php $var=$r_section['field']; echo"$var";?>"> <?php $var=$r_section['field']; echo"$var";?> <?php }?> </select> <?php } ?> Hope it helps. Link to comment https://forums.phpfreaks.com/topic/93265-dynamic-list/#findComment-477715 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.