newbeee Posted January 10, 2009 Share Posted January 10, 2009 if the category pull down menu is changed then the list in the topics pull down menu changes to show the topics that are in that category chosen. all data is got from the mysql database. there maybe a lot of categories and topics in the furture, just in case that may help in creating a method to prevent the code needing changing again in the future, due to taking too long or something? <select name="categoryid"><? // get category_id $get_category_titles = mysql_query("SELECT * FROM `forum_category` WHERE `confirmed` = '1' ORDER BY `created_on` DESC"); $get_topic_titles = mysql_query("SELECT * FROM `forum_topics` WHERE `confirmed` = '1' ORDER BY `created_on` DESC"); for ($i = 0; $i < mysql_num_rows($get_category_titles); $i ++) { ?><option<? if ($posts['categoryid'] == mysql_result($get_category_titles, $i, 'category_id')) {echo(" selected");} ?> value="<?=mysql_result($get_category_titles, $i, 'category_id');?>"><?=mysql_result($get_category_titles, $i, 'category');?></option><? } ?></select> <select name="topicid"><? // get topics for ($i = 0; $i < mysql_num_rows($get_topic_titles); $i ++) { ?><option<? if ($posts['topicid'] == mysql_result($get_topic_titles, $i, 'topic_id')) {echo(" selected");} ?> value="<?=mysql_result($get_topic_titles, $i, 'topic_id');?>"><?=mysql_result($get_topic_titles, $i, 'topic');?></option><? } ?></select> Link to comment https://forums.phpfreaks.com/topic/140280-selecting-option-on-menu-a-changes-the-options-available-in-menu-b/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.