Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5991633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:24:55+00:00 2026-05-22T23:24:55+00:00

I have 2 drop down list, one is college and other is branch, so

  • 0

I have 2 drop down list, one is college and other is branch, so what i want to do is that whenever a user selects a college from the first drop down list, the script should automatically check for the branches available in that college and should add them to the second drop down list i.e. of branches, currently I am doing it manually.

<?php
mysql_connect("localhost", "root", "") or die("Connection Failed");
mysql_select_db("pet")or die("Connection Failed");
$query = "SELECT distinct insti_name FROM maininfo";
$result = mysql_query($query);




$query2 = "SELECT distinct insti_name FROM maininfo";
$result2 = mysql_query($query2);

?>
<form name="myform" id="one" method="post" action="compare.php">
Select first college: 
<select name="coll1">
<?php
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
?>
<option value="<?php echo $line['insti_name'];?>"> <?php echo $line['insti_name'];?>
</option>

<?php
}
?>
</select>
<br /><p>Select the branch:


<select name="brn1">

<option value="0" selected>(please select:)</option>
<option value="ce">Civil</option>
<option value="cse">Computer Science Engineering</option>
<option value="ec">Electronics and Communication</option>
<option value="it">Information Technology</option>
<option value="aeie">AEIE</option>
<option value="mech">Mechanical</option>
<option value="elect elex">Elect Elex</option>
<option value="ee">Electricals</option>
<option value="el">EL</option>
<option value="chem">Chemical</option>
<option value="fire">Fire</option>
<option value="ei">ei</option>
<option value="food">Food</option>
<option value="ip">Information Practises</option>
<option value="bt">Bio Technology</option>

</select>


<br>
<hr width=100% height=4>

Select second college: 
<select name="coll2">
<?php
while ($line = mysql_fetch_array($result2, MYSQL_ASSOC)) {
?>
<option value="<?php echo $line['insti_name'];?>"> <?php echo $line['insti_name'];?>
</option>

<?php
}
?>


</select>


<br /><p>Select the branch:
<select name="brn2">
<option value="0" selected>(please select:)</option>
<option value="ce">Civil</option>
<option value="cse">Computer Science Engineering</option>
<option value="ec">Electronics and Communication</option>
<option value="it">Information Technology</option>
<option value="aeie">AEIE</option>
<option value="mech">Mechanical</option>
<option value="elect elex">Elect Elex</option>
<option value="ee">Electricals</option>
<option value="el">EL</option>
<option value="chem">Chemical</option>
<option value="fire">Fire</option>
<option value="ei">ei</option>
<option value="food">Food</option>
<option value="ip">Information Practises</option>
<option value="bt">Bio Technology</option>

</select>
<br><br>
<input type="submit" name="Submit" value="Compare Colleges" >
</form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:24:56+00:00Added an answer on May 22, 2026 at 11:24 pm

    As a note, this is a better user-experience if done with AJAX. However, you need to set your form to submit onchange of your college select box. Then, in your PHP, you need to do:

    if( isset( $_POST['coll1'] ) ) {
        //query your branches and populate select same as you did for colleges.
        //e.g. "SELECT * FROM Branches WHERE CollegeId=".mysql_real_escape_string($_POST['coll1']);
    }
    

    Is that enough info for you to work from?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 drop-down menus. User selects something from the first one, then the
I have two drop down list on a page. The first one list projects
I have a drop down list on one form that populates a puzzle id
I have one drop down list in my page, which contains two options. What
I have a drop down list that has options that need to be passed
I have a drop down list that triggers an updatepanel when the index is
I have a drop-down list hardcoded in an MVC View User Control page and
I have a drop down list that is populated with data in the code
I have a drop down list and I want the selected value to put
I have three drop down list <h:selectOneMenu> , and a <p:dataTable> . I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.