Jump to content

selecting option on menu A changes the options available in menu B


newbeee

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.