php - 从数据库中选择 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>
任何参考任何评论都会有所帮助,谢谢
解决方案
你必须做这样的代码才能从你的数据库中获取价值
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>
推荐阅读
- r - 抓取网页的全部内容
- javascript - 为什么 useEffect 不是构造函数?
- reactjs - react-window children 作为 itemData 结果总是重新渲染
- reactjs - 想要在反应路由路由器中传递多个组件
- javascript - Laravel Mix 我无法访问我的 javascript 类
- java - 当 args[0] 不起作用时我该怎么办?JDA 生成器
- c# - EF Core标签映射UsingEntity,如何防止它重新插入现有关系?
- docker - 如何使用 dockerode 或 docker api 在多主机群上模拟“docker service ps”?
- javascript - 浏览器请求在 setInterval 中声明的相同文件
- azure - 将 Azure B2C 限制为组织帐户