xcandiottix Posted July 20, 2010 Share Posted July 20, 2010 I want to check my database's "Category" row, then use that information to create a drop down of every category with in that row. I don't want to same category to appear twice tho. I think this could be a lengthy answer for anyone to give so does anyone know a good "how to" already on this subject? <form action=""> <select name="category" onchange="showCategory(this.value)"> <option value="">Select a category:</option> <?php $con = mysql_connect(".com","UN","PW"); mysql_select_db("DB", $con); $data = mysql_query("SELECT * FROM application_directory") or die(mysql_error()); while($info = mysql_fetch_array($data)){ echo '<option value="'.$info["db_Appcategory"].'">'.$info["db_Appcategory"].'</option>'; } ?> </select> </form> I have this so far to test, and it works but obviously it will just create one item in the drop down. Any help is greatly appreciated =) *edit- I've added the while loop so that way it will create a new item for each row Link to comment https://forums.phpfreaks.com/topic/208324-select-from-list-to-create-drop-down/ Share on other sites More sharing options...
dezkit Posted July 20, 2010 Share Posted July 20, 2010 $data = mysql_query("SELECT DISTINCT db_Appcategory FROM application_directory") or die(mysql_error()); Not sure what you're trying to ask, but the sql above will only echo unique db_Appcategorys, no multiples. Link to comment https://forums.phpfreaks.com/topic/208324-select-from-list-to-create-drop-down/#findComment-1088741 Share on other sites More sharing options...
xcandiottix Posted July 20, 2010 Author Share Posted July 20, 2010 $data = mysql_query("SELECT DISTINCT db_Appcategory FROM application_directory") or die(mysql_error()); Not sure what you're trying to ask, but the sql above will only echo unique db_Appcategorys, no multiples. Thanks for understanding my mumbo jumbo... that's EXACTLY what I needed... thanks! Link to comment https://forums.phpfreaks.com/topic/208324-select-from-list-to-create-drop-down/#findComment-1088749 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.