列表框填充但不工作的PHP

时间:2015-11-18 17:24:54

标签: php forms combobox

我尝试使用站点中给出的代码来填充引导程序组合框。我在php文件中添加并更改了代码,并尝试在表单之前包含该文件。但整个表格都消失了。当我删除include php语句时,它再次出现。 为什么以及如何做,使代码插入此处并填充列表框,类似地,该表由两个字段的pincode和place组成。当pincode填充在组合上时,用户选择一个密码,然后表格中的适当位置应列在下一个文本框中。谢谢你的帮助

<?php include 'pincode.php';?>
               <!-- middle column-->
            <div class="col-md-8">
                <div class="panel panel-default">
                <div class="panel-heading">
                    <h5 class="">Enter details of your school</h5>
                </div>
                <div class="panel-body">
                   <form data-toggle="validator" role="form">
  <div class="form-group textareawidth has-feedback">
    <label for="address">Enter school address</label>
    <textarea class="form-control" pattern = "^[_A-z0-9]{1,}$" maxlength="150" rows ="3" name = "saddress" id="address" placeholder="Enter address with out pincode" required></textarea>
    <span class="glyphicon form-control-feedback" aria-hidden="true"></span>
    <span class="help-block with-errors"></span>
  </div>
  <div class="form-group textareawidth">
  <label for="pin">Select list:</label>
  <select class="form-control" id="pin" name ="pin_code">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
   </select>
</div>
<div class="form-group textareawidth">
    <label for="place">Place</label>
    <input type ="text" class="form-control" name = "splace" id="place" required>
    <span class="glyphicon form-control-feedback" aria-hidden="true"></span>
    <span class="help-block with-errors"></span>
</div>

我在这里已经包含了表格的一部分。 php文件由代码

组成
<?php
$dbcon1=mysqli_connect( "localhost", "root","","simple_login") or die(mysql_error());
mysqli_select_db( $dbcon1,"" ) or die(mysql_error());

$check_place = "SELECT * country FROM pincode";
$run=mysqli_query($dbcon1,$check_place);

while($check_place = mysqli_fetch_array( $run ))
{

    $pin_code = $pincode['pin'];
    $pin_place = $country['place'];

    $pin_block .= '<OPTION value="'.$pim_code.'">'.'</OPTION>';
}
?>

1 个答案:

答案 0 :(得分:0)

$ check_place =&#34; SELECT * country FROM pincode&#34 ;;

mysql语句中有错误。

更改为

$ check_place =&#34; SELECT * FROM pincode&#34 ;;

这将从表中获取所有行