syamswaroop Posted May 4, 2009 Share Posted May 4, 2009 <table width="150"> <tr> <td align="left" class="style31">Category</td> <td align="right" class="style31"><select name="cat" class="style31" onchange="submit();"> <option value=""> <--------Select--------> </option><?php include("dbconn.php"); $result = mysql_query("select * from dg_category"); while($row = mysql_fetch_array($result)) {?> <option value= "<?php echo $row[0]; ?>" <?php if(strcmp($_POST['cat'],$row[0]) == 0) { echo "selected"; }//if ?>> <?php echo $row[1]; ?> </option><?php }//while ?> </select></td> </tr> <?php if($_POST['cat']) { ?> <tr> <td align="left" class="style31"> class/Specialization</td> <td align="right"> <select name="class1" class="style31" onchange="submit();"> <option value=""> <--class--> </option><?php $cat = $_POST['cat']; $result = mysql_query("select * from dg_class where category_id ='$cat'"); while($row = mysql_fetch_array($result)) {?> <option value= "<?php echo $row[0]; ?>" <?php if(strcmp($_POST['class1'],$row[0]) == 0) { echo "selected"; }//if ?>> <?php echo $row[1]; ?> </option><?php }//while ?> </select> </td> </tr> <?php } else { $_POST['class1'] = NULL;} ?> <!--if category --> <?php if($_POST['class1']) { ?> <tr> <td class="style31"><div align="left">SessionTimings</div></td> <td><div align="right"> <select name="session" class="style31" onchange="submit();"> <option value=""><---select---></option> <option value="1" <?php if($_POST['session'] == 1) echo "selected"; ?>>Morning(6AM - 2PM)</option> <option value="2" <?php if($_POST['session'] == 2) echo "selected"; ?>>Evening(2PM - 10PM)</option> </select> </div></td> </tr> <?php } else { $_POST['session'] =NULL ; } ?> <?php if($_POST['session']) { ?> <tr> <td align="left" class="style31">subject</td> <td align="right"> <select name="sub" class="style31" onchange="submit()"> <option value=""> <--Subject--> </option><?php $class = $_POST['class1']; $result = mysql_query("select * from dg_subject where class_id ='$class'"); while($row = mysql_fetch_array($result)) {?> <option value= "<?php echo $row[0]; ?>" <?php if(strcmp($_POST['sub'],$row[0]) == 0) { echo "selected"; }?>> <!--if --> <?php echo $row[1]; ?> </option><?php }?> <!--while --> </select> </td> </tr> <?php } else { $_POST['sub'] = NULL; } ?> <?php if($_POST['sub']) {?> <tr class="style31"> <td colspan="2"> <table border="1"> <tr> <th colspan="4" align="center" width="300" class="style31">Topics</th> </tr> <?php $sub = $_POST['sub']; $result = mysql_query("select * from dg_subject_topic where subject_id ='$sub'"); if( mysql_num_rows($result) <= 0) {?> <tr> <td colspan="4" align="center"> NO Topics </td> </tr> <?php } else {?> <tr> <td width="35">Select</td> <td width="134">TopicName</td> <td width="32">Cost</td> <td width="48">Duration</td> </tr><?php while($row = mysql_fetch_array($result)) {?> <tr> <td align="left"><input type="radio" name="list" id="list" value="<?php echo $row[0];?>" <?php if($_POST['list'] == $row[0]) { echo "checked"; } ?>/> </td> <td align="left"><?php echo $row[1]; ?> </td> <td align="left"><?php echo $row[4]; ?> </td> <td align="left"><?php $duration = $row[3]; $_SESSION['duration'] = $duration; echo $row[3]; ?> </td> </tr><?php }// while ?> <tr> <td class="style31" colspan="4" align="center"> <input type="hidden" name="hid" id="hid" value= "<?php if($_POST['cat']) { echo $_POST['hid']; } ?>" /> <a href="javascript:document.sstw.submit()" onclick="submitform1('1','hid'); ">submit</a> </td> </tr> </table> </td> </tr> <?php } // else } else { $_POST['hid'] = NULL; } //if (sub) ?> </table> everything is working fine if we go in order atlast topics are displayed perfectly but suddenly if i change the first combo box i.e select category only select class should be displayed bcoz class depends on category selected . what to do for getting this Link to comment https://forums.phpfreaks.com/topic/156785-combo-box-not-working-fine/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.