从select标记获取值时出错 - PHP

时间:2017-04-30 11:04:38

标签: php html select drop-down-menu

代码运行时我无法获得任何价值,请帮助

HTML部分:

<form method="post">
    <select name="rebuild">
        <?php while($lo = mysqli_fetch_assoc($resultt)) { ?>
            <option value="<?php echo $lo["company_name"]; ?>">
                <?php echo $lo["company_name"]; ?>
            </option>
        <?php } ?>
    </select>       
</form>

PHP部分:

if (isset($_POST['rebuild'])) {
    $re = $_POST['rebuild'];
}
else {      
   $re = " ";
}

echo $re;   

1 个答案:

答案 0 :(得分:0)

试试这个

<form method="post">
<select name="rebuild">
    <?php while($lo = mysqli_fetch_assoc($resultt)) { ?>
        <option value="<?php echo $lo["company_name"]; ?>">
            <?php echo $lo["company_name"]; ?>
        </option>
    <?php } ?>
</select>  
<input type="submit" name="submit">     
</form>

你的PHP部分

if (isset($_POST['submit'])) {
$re = $_POST['rebuild'];
echo $re;
exit();
}