[英]Select from database MySQL show value in input text html select by value from another input text 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>
任何引用任何評論將有所幫助,謝謝
1)對您需要的數據進行選擇查詢。
2.)然后在輸入字段的value屬性中回顯值
例如。
$res = $con->query('Select * from barcode where `id`=1');
$ row = $ res-> fetch_assoc();
<input type='text' id="barkode" name='barkode' value='<?php echo $row['barcode']?>'>
您必須執行這樣的代碼才能從數據庫中獲取價值
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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.