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> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.