首页 > 解决方案 > 从数据库中选择 MySQL 在输入文本 html 中显示值 从另一个输入文本 html 中按值选择

问题描述

嗨再次堆栈溢出,我想显示来自 MySQL 数据库的值并以相同的形式显示它,这可能吗?

我有这样的html表单:

<td>Barcode/td> <<-- select from database by barcode input text and show result to input text dname, three, four, five
<td><input type='text' id="barkode" name='barkode'/></td>   
<td>Name</td>
<td><input type='text' id="dname" name='dname'/></td>   
<td>three</td>
<td><input type='text' id="three" name='three' /></td>    
<td>four</td>
<td><input type='text' id="four" name='four'/></td>  
<td>five</td>
<td><input type='text' id="five" name='five' /></td>  

任何参考任何评论都会有所帮助,谢谢

标签: phphtmlmysql

解决方案


你必须做这样的代码才能从你的数据库中获取价值

include('yourConnection');
    $sql="SELECT * FROM TabmeName WHERE id="$id";
        $result = mysqli_query($conn,$sql);
    if($result) {
            if(mysqli_num_rows($result) > 0) {
             $row = mysqli_fetch_assoc($result);   
           $name = $row['barkode'];
    }
}

输入

  <td><input type='text' id="barkode" name='barkode' value="<?php echo $name ?>"/></td>

推荐阅读