在php中参数化动态下拉列表

时间:2015-07-02 21:25:03

标签: php html mysql drop-down-menu

我一直在尝试获取它,以便我可以将变量分配给用户在国家/地区下拉菜单中选择的值。我之前用表格做过这个,但没有下拉列表,所以我不确定如何做。最后,我试图让用户点击提交按钮后,为所选国家/地区返回一个新页面,并且知道我需要为用户选择的内容分配一个变量。到目前为止,这是我的代码:

<html>
<head>
  <title>test2</title>
  <link href="css/style.css" rel="stylesheet">
</head>

<body> 
<?php include("header.php"); ?> 
    <article>   
    <!-- This describes the choice of country name selection -->
        <h1>Please select your country:</h1>

        <form action='processformD.php' method='GET'>
            <select name='CountryName'>

<?php
                $query = "SELECT * FROM alphabetizedCountryNames;";
                $result=mysqli_query($con, $query) or die ("Couldn't execute query.");
                // $row = mysqli_fetch_assoc($result);
                ?>
                <?php
                while($row = mysqli_fetch_array($result))
                {
                    extract($row);
                    echo "<option value='$CountryName'>$CountryName\n";
                }
                ?>
            </select>


<div class="centerthatshit"><?php echo "<p><input type='submit' value='submit' /></p>\n"; ?></div>
        </form>

</article>   
<?php include("footer.php"); ?> 

</body>
</html>
</body>
</html>

0 个答案:

没有答案