我有一个表单数据从数据库中选择数据。我希望每个所选项目的单位在相应的单位输入表格中回显。请问我需要一种解决这个问题的简化方法。 这是表格:
<?php include ("header.php");?>
<?php
$start=1;
$end= $_POST['item'];
for($start;$start<=$end;$start++){
require("connect.php");
$sql = "(SELECT * FROM drug_name)";
$result = mysqli_query($conn, $sql);
?>
<form align="center" method="post" action="transactions.php" id='myform'>
Name:
<select align="right" name="inputname[]" id='Drug_item_Name'
value="Drug_Item_Name"><option selected="selected" value="0">S/N Select drug --</option>
<?php while($row = $result->fetch_assoc()){ ?>
<option ><?php echo$row['Drug_Item_Name']?></option>
<?php
}
?>
</select>
<td align="right">Unit:</td>
<td><input type="text" name="input2[]"
placeholder="Enter UNIT" size="7" ></td>
<td align="right">QTY:</td>
<td><input type="text" name="input3[]" placeholder="Enter QTY" size="5"></td>
</tr>
<?php echo '<br>'; ?>
<?php }
?>
<td><INPUT TYPE="submit" NAME=Dispense" SIZE="10" value="Dispense"></td></table></form>
</form>