0

我正在用 PHP 和 Mysql 创建一个网站。下面有一个上传表格:

<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post" 
enctype="multipart/form-data" accept-charset="utf-8">

<table width="900" border="0" cellspacing="10" cellpadding="0">
<tr>
<td width="150">Medium</td>
<td>
<select class="td" name="medium">
    <option selected="selected" value="">Select..</option>
    <?php

    $sql = mysql_query("SELECT * FROM medium WHERE s_id = 0");
    while($re = mysql_fetch_array($sql))
    {
        $re_medium = 
mysql_real_escape_string(trim($re['name']));        
        $sel2 = '';
        if($re_medium == $_POST['medium'])
        {
            $sel2 = 'selected = "selected"';    
        }   
        echo "<option value='$re_medium'".$sel2."> $re_medium 
</option>";         
    }
    ?>  
</select>
</td>
</tr>
<tr>
<td>Class</td>
<td>
<select class="td" name="class">
    <option selected="selected" value="">Select..</option>
    <?php        
    $sql2 = mysql_query("SELECT * FROM class");
    while($re2 = mysql_fetch_array($sql2))
    {
        $re_class = 
mysql_real_escape_string(trim($re2['c_name']));         
        $sel = '';
        if($re_class == $_POST['class'])
        {
            $sel = 'selected = "selected"'; 
        }   
        echo "<option value='$re_class'".$sel."> $re_class 
</option>";         
    }
    ?>  
</select>
</td>
</tr>

<tr>
<td>Subject</td>
<td>
<select class="td" name="subject">
    <option selected="selected" value="">Select..</option>
    <?php        
    $sql2 = mysql_query("SELECT * FROM subject");
    while($re2 = mysql_fetch_array($sql2))
    {
        $re_class = 
mysql_real_escape_string(trim($re2['subject_name']));       
        $sel = '';
        if($re_class == $_POST['subject'])
        {
            $sel = 'selected = "selected"'; 
        }   
        ?>
         <option value="<?php echo $re2['id'] . '|' . $re2['subject_name'] ?>" <?php 
echo $sel; ?>><?php echo $re2['subject_name'] ?></option>   
        <?php
        //echo "<option value='$re_class'".$sel."> $re_class    
</option>";         
    }
    ?>  
</select>
</td>
</tr>
</table>
</form>

好吧,所以我的问题是,有没有办法在不同的选择项目上显示不同的选项名称。

例如:如果我从 html Select 标签中选择英文名称,那么所有的类名都应该显示在这个类别下,然后如果我从Class name 中选择O 级别,那么所有的主题都应该显示在这个类别下。只是动态变化!

对不起我的英语不好。谢谢你。

4

0 回答 0