从下拉列表中选择显示特定ID的记录,并在html表中显示相关记录

时间:2017-09-14 10:57:56

标签: javascript php jquery json

我希望用户点击下拉列表并选择考试类型。只有与该ID相关的特定记录才会显示在表格中。 我下面有两张图片是图片。

enter image description here

<select name="exam_type_id">
         <option value="Select">Select</option>
    <?php 
         $result= new exam();
         $res=$result->selectExam();
          while($t=mysqli_fetch_array($res))
            { 
    ?>
            <option value="<?php echo $t['exam_type_id']?>">
            <?php echo $t['name']; ?></option> <?php }?>
        </select>
   </form>
      <div class="inside">
            <table width="605" height="70" border="2" bordercolor="#666666">
              <tr>
                <td><strong>Class Name</strong></td>
                <td><strong>Subject</strong></td>
                <td><strong>Start Date</strong></td>
                <td><strong>End Date</strong></td>
                <td><strong>Room No</strong></td>
                <td><strong>Add</strong></td>
                <td><strong>Edit</strong></td>
                <td><strong>Delete</strong></td>
              </tr>
        <?php 
             $result= new exam();
             $res=$result->selectExamAll();
             while($res1=mysqli_fetch_array($res))
             { ?>
               <td><?php echo $res1["className"]; ?> </td>
                <td><?php echo $res1["subject"]; ?></td>
                <td><?php echo $res1["startDate"]; ?></td>
                <td><?php echo $res1["endDate"]; ?></td>
                <td><?php echo $res1["roomNo"]; ?></td>
                <td><a href="addExam.php"><img src="images/add.jpg" width="20" height="20"/></a></td>
                <td>
                  <a href="addExam.php">
                  <img src="images/add.jpg" width="20" height="20"/></a>
                </td>
                <td><a href="addExam.php"><img src="images/add.jpg" width="20" height="20"/></a></td>
              </tr> 
        <?php } ?>
            </table>
            <p class="p0">
            </p>enter code here
   </div>

exam_type_id exam_type 表中的外键。我在 exam_type 表的下拉列表中显示考试类型。当用户点击来自exam_type表的下拉数据时,基于所选id的特定数据应该显示在html表中。 exam_type_id 来自 exam_type 表,其在考试table.id中的外键将来自 exam_type 下拉列表,数据将显示在考试表中html表。

0 个答案:

没有答案