Jump to content

multiple dynamic drop down menu


rags_asr

Recommended Posts

hii,everyone...

i am new to the forum ..so forgive me if i make some errors in describing my problem

 

i want to create a drop down menu...the values of which i want to retrieve from a table i have created in my database...

i have been able to acheive this...but i want a second drop down menu...in which i want the values to get filtered according to the selection of the first drop down menu...

i hav a table with the name test...which i am connecting to the first drop down menu

i hav created another table with the name testtype...for second menu..

the id of first table is the testid of second...

plzz help me with creating the second menu...

 

my code is

   <?php
$sql_result = "select test_series FROM test";
$result = mysql_query($sql_result); 
?>
	<td>Select Test Series </td>
         <td>
        <select name="testseries" id="testseries" )">
        <option>Select</option>
        <?php  if(mysql_num_rows($result)) 
    { 
    while($row = mysql_fetch_assoc($result)) 
    { 
$test = $row['test_series'];?>
    <option><?php echo $test ?></option>
    <?php } 

    } 
    else {?>
    <option>No Names Present</option>";  
   <?php } 
    ?>
    </select>
    </td>
    </tr>
    
     <tr>
<?php
$testseries = $_POST['testseries'];
$query = "select id from test where test_series = '$testseries'";
$resultt = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($resultt);
$id = $row['id'];

$sql_result = "select test_name FROM testtype where testid = $id";
$result = mysql_query($sql_result); 
?>
	<td>Select Test Name </td>
         <td>
        <select name="testtype">
        <option>Select</option>
        <?php  if(mysql_num_rows($result)) 
    { 
    while($row = mysql_fetch_assoc($result)) 
    { 
$test2 = $row['test_name'];?>
    <option><?php echo $test2 ?></option>
    <?php } 

    } 
    else {?>
    <option>No Names Present</option>";  
   <?php } 
    ?>
    </select>
    </td>
    </tr>




 

 

IN THIS CODE I AM GETTIN AN ERROR Undefined index: testseries in ..addques.php on line 155 WHICH IS THIS ONE $testseries = $_POST['testseries'];

Link to comment
https://forums.phpfreaks.com/topic/247835-multiple-dynamic-drop-down-menu/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.