如何使用html和php回显输入类型文本中的数据库值?

时间:2017-08-01 11:41:47

标签: php html sql

我试图回显数据库中提取的值。但它在输入中显示未定义的变量问题

这是我的PHP代码

<?php 

      if(isset($_POST['load']))
      { 
       $bno= $_POST['select'];
       $con =  mysqli_connect("localhost","root","","db_bus") or die("connection failed".mysql_connect_error());
                    $query = "select * from bus_master where b_no = '$bno' ";

                    $result = mysqli_query($con, $query);

                  $row = mysqli_fetch_array($result);

                        if(!$row)
                        {
                           echo 'There is no such entry for  :  '. $bno  ;

                        }

                            $id =  $row['b_id'] ;
                            $name = $row['b_name']; 
                            $no =  $row['b_no'] ;
                            $type =   $row['b_type'];
                            $sorce =  $row['b_ss'];
                            $dest =  $row['b_ds'];
                            $dep =  $row['b_dt'] ;
                            $reach = $row['b_rt'];   


                            mysqli_close($con);    

}

      ?>

这是我的HTML代码

  <div >
      <label >Bus id :</label>
      <input  type="text" name="b_id" value="<?php echo $bid?>" placeholder="Enter bus id" required>

              <br>
              <button   name="btn_add" style="width: 260px"> Add</button>
          </div>

0 个答案:

没有答案