从下拉列表中选择后获取数据,并使用表格数据均衡所选值

时间:2015-05-19 10:18:17

标签: php html mysql

我想选择测试名称,在选择测试名称后,想要从“mst_result”表中获取所有值,其中测试名称等于我在drop sown列表中选择的值。目前我的上帝是这样的,但我没有得到如何获得所选测试名称的值。

<form name="form1" method="post" onSubmit="return check();">
<table> 
<tr>
<td>Test Name </strong></div></td>
<select name="test" id="test">
<option value=""><------></option>
<?php
$rs=mysql_query("Select * from mst_test order by  test_name",$cn);
while($row=mysql_fetch_array($rs))
{
    if($row[0]== $rs['test_id'])
    {
        echo "<option value='$row[0]' selected>$row[2]</option>";
    }
    else
    {
        echo "<option value='$row[0]'>$row[2]</option>";
    }
}
?>
</select>
<td align="left" ><input type="submit" name="res" value="Submit" /> </td>
</tr>
</table>
</form>
if(isset($_POST['res']))
{
    $qr=mysql_query("Select * from mst_result order by login where test_id='$test' ",$cn);
    $ii=1;
    while($rr1=mysql_fetch_array($qr)){
        $qr1=mysql_query("SELECT * FROM mst_result order by login");
        $rr1 = mysql_fetch_array($qr1);
        $qr2 = mysql_query("SELECT * FROM mst_result order by score");
        $rr2 = mysql_fetch_array($qr2);
        ?>
        <table>
        <tr>
        <td><?php echo $ii;?></td>
        <td><?php echo $rr1['login'];?></td>
        <td><?php echo $rr2['score'];?></td>
        </tr>   
        <?php
        $ii++;
    }}
?>

0 个答案:

没有答案