PHP-在文本框中显示数据库值

时间:2018-12-13 00:57:20

标签: php mysql forms input phpmyadmin

截至目前,当我单击“提交”按钮时,文本框中未显示任何内容。我正在提交id,以便该程序知道要查找的字段。

编辑

我的提交和输入类型名称id

 <form action="" method="POST">
          <div class="row  col-md-4">
          <label>Code</label>
           <input type="text" name="id" class="form-control validate" id="mapo"> 
             <br>
          <input type="submit" class="form-control btn-warning" name="search" value="Search Data"></input><br>

在phpmyadmin数据库中连接我的php:

$connection = mysqli_connect("localhost","root","");
$db = mysqli_select_db($connection, 'qrproject');

这是单击按钮时我的isset语句,然后将弹出文本框

 if(isset($_POST['search']))
          {
            $id = $_POST['id'];

            $query = "SELECT * FROM scratch_cards WHERE id='$id' ";
            $query_run = mysqli_query($connection, $query);

            while($row = mysqli_fetch_array($query_run))
            {
              ?>
              <form action="" method="POST">

                <input type="hidden" name="id" value="<?php $row['id'] ?>" class="form-control validate">

              <label>PIN</label>
                 <input type="text" name="pin" value="<?php $row['pin'] ?>" class="form-control validate" id="mact">
                <br>

              <label>Price</label>
              <input type="number" name="amount" value="<?php  $row['amount'] ?>" class="validate form-control" id="soluong">
                <br>


              <label>Card Expiration</label>
              <input type="date" name="card_expiration" value="<?php  $row['card_expiration'] ?>" class="validate form-control" id="cardex">
                <br>


              <label>Card Validity</label>
                <input type="text" name="card_validity" value="<?php  $row['card_validity'] ?>" class="validate form-control" id="cardval">
                <br>

              <label>Status</label>
              <input type="text" name="status" value="<?php  $row['status'] ?>" class="validate form-control" id="stats">
                <br>
 </form>
              <?php 
            }
          }
           ?>   
      </form>

1 个答案:

答案 0 :(得分:2)

第二个文件中的所有代码都没有打印命令。

更改自

<input type="hidden" name="id" value="<?php $row['id'] ?>" class="form-control validate">

<input type="hidden" name="id" value="<?php echo $row['id'] ?>" class="form-control validate">

对每个输入都执行此操作,一切都会正常工作。