表单无法使用 mysql 获取 php 中的值

Form cannot get the value in php using mysql

我的旧 HTML 程序工作正常。

<body>
<h1 align="center" class="color"> Welcome advanced Search </h1>
<center>
<div>
<label>Field:</label> 
<select name="country" class="country">
<option selected="selected">--Select Field--</option>
<?php
    $stmt = $DB_con->prepare("SELECT * FROM country");
    $stmt->execute();
    while($row=$stmt->fetch(PDO::FETCH_ASSOC))
    {
        ?>
        <option value="<?php echo $row['country_id']; ?>"><?php echo $row['country_name']; ?></option>
        <?php
    } 
?>
</select>
<label>Department :</label> 
<select name="state" class="state">
<option selected="selected">--Select Department--</option>
</select> 

而不是使用 Bootstrap 到 implement/Integrate 代码。如下所示。

<form class="form-inline form_search_form testingForm" autocomplete="off"  style="display:block" >

 <div class="row">                  

                  <div class="col-lg-3 col-sm-4 col-xs-12">
                    <select title="Field" data-placement="left" name="country" class="form-control" class="country">
                        <option selected="selected"> -- Field -- </option>
  <? php
    $stmt = $DB_con->prepare("SELECT * FROM country");
    $stmt->execute();
    while($row=$stmt->fetch(PDO::FETCH_ASSOC))
    {
        ?>
        <option value="<?php echo $row['country_id']; ?>"><?php echo $row['country_name']; ?></option>
        <?php
    } 
 ?>                   

                     </select>

                     </div> 

什么问题?。在这种情况下,我正在使用 or else ?.

我很困惑,请帮助我们。 实际上我需要从 mysql 获取数据到我的网站 。 ?

<form class="form-inline form_search_form testingForm" autocomplete="off"  style="display:block" >

 <div class="row">                  

                  <div class="col-lg-3 col-sm-4 col-xs-12">
                    <select title="Field" data-placement="left" name="country" class="form-control" class="country">
                        <option selected="selected"> -- Field -- </option>
  <?php
    $stmt = $DB_con->prepare("SELECT * FROM country");
    $stmt->execute();
    while($row=$stmt->fetch(PDO::FETCH_ASSOC))
    {
        ?>
        <option value="<?php echo $row['country_id']; ?>"><?php echo $row['country_name']; ?></option>
        <?php
    } 
 ?>                   

                     </select>

                     </div> 

正确的代码:

<form class="form-inline form_search_form testingForm" autocomplete="off"  style="display:block" >

 <div class="row">                  

                  <div class="col-lg-3 col-sm-4 col-xs-12">
                    <select title="Field" data-placement="left" name="country" class="form-control" class="country">
                        <option selected="selected"> -- Field -- </option>
  <?php
    $stmt = $DB_con->prepare("SELECT * FROM country");
    $stmt->execute();
    while($row=$stmt->fetch(PDO::FETCH_ASSOC))
    {
        ?>
        <option value="<?php echo $row['country_id']; ?>"><?php echo $row['country_name']; ?></option>
        <?php
    } 
 ?>                   

                     </select>

                     </div> 
</form>

</form> 结束元素并使用 <?php 而不是 < ?php

使用这个:

Select 字段 准备("SELECT * FROM country"); $stmt->执行(); while($row=$stmt->fetch(PDO::FETCH_ASSOC)) { ?> ">