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>