我从我的数据库中的一个表中填充我的下拉列表。我试图抓住用户选择的下拉列表中的选定项目,以便我可以查询数据库以获取与该项目相关的更多信息。
<html>
<head></head>
<body>
<br>    
<table id ="topnav" width="1100" border="0" align="center">
    <tr>
    <td colspan="2" style="background-color:#FFA500;">
    <h1><table border="0">
    <tr>
    <th colspan="6"><img src ="../_images/Eu_flags.jpg" border="0" align="top" width="1100" height="180" />
    </th>
    </tr>
<table></h1>
    </td>
    </tr>
    <tr valign="top">
    <td style="background-color:#FFD700;width:150px;text-align:top;">
    <b>Menu</b><br />
    Select the state<br>
    See rank of Universities<br />
    Other information
    </td>
    <td style="background-color:#eeeeee;height:100px;width:940px;text-align:top;">
<?php
        $con = mysql_connect("localhost","root","pasword");
        if (!$con)
        {
            die('Could not connect: ' . mysql_error());
        }
        mysql_select_db("test", $con);
        if (!$con)
        {
            die('Could not connect: ' . mysql_error());
        }
        $result = mysql_query("SELECT lnamestate FROM state" );
        while($row = mysql_fetch_array($result))
        {
        $lnamestate_id = $lnamestate['id'];
        $row_lnamestate=$row['lnamestate'];
        $row_block .= '<OPTION value="'.lnamestate_id.'">'.$row_lnamestate.'</OPTION>';
        }
        mysql_close($con);
?>  
        <label for="row">Select state</label>
        <select name="lnamestateID"><?php echo $row_block; ?></select>
    </td>
    </tr>
    <tr>
    <td colspan="2" style="background-color:#FFA500;text-align:center;">
    </td>
    </tr>
</table>
</table>
</body>
</html>