为了账号安全,请及时绑定邮箱和手机立即绑定

如何将表中导入的sql值复制到文本框中?

如何将表中导入的sql值复制到文本框中?

PHP
人到中年有点甜 2021-04-26 16:13:24
我已经创建了一个表,并且正在从mySQL数据库中提取数据。我已经创建了3列,并希望采用第3列(建议数量)并将这些值复制到第4列的一行文本框中(订购数量),以便用户可以对其进行编辑。我该怎么做呢?$sql = "SELECT item_price.item_id, item_price.ITEM_NAME,suggested_qty,Price_itemFROM item_price JOIN suggested_item  ON item_price.ITEM_NAME = suggested_item.ITEM_NAME";$result = $conn->query($sql);?><tr><th> ID</th><th>Item Name</th><th>Suggested Quantity</th><th>Order Quantity</th><th>Total Cost ($)</th></tr><?phpwhile ($row = $result->fetch_assoc()) {    echo "<tr>";    echo "<td>" . $row['item_id'] ."</td>";    echo "<td>" . $row['ITEM_NAME'] . "</td>";    echo "<td>" . $row['suggested_qty'] . "</td>";}?></table>
查看完整描述

1 回答

?
慕沐林林

TA贡献2016条经验 获得超9个赞

您应该首先将表格包装成表格,然后在带有输入文本字段的列中添加建议的数量。这样的事情应该可以帮助您入门:


$sql = "SELECT item_price.item_id, item_price.ITEM_NAME,suggested_qty,Price_item

FROM item_price JOIN suggested_item  

ON item_price.ITEM_NAME = suggested_item.ITEM_NAME";

$result = $conn->query($sql);

?>

<form action="#" method="post">

<table>

<tr>

<th> ID</th>

<th>Item Name</th>

<th>Suggested Quantity</th>

<th>Order Quantity</th>

<th>Total Cost ($)</th>

</tr>


<?php

while ($row = $result->fetch_assoc()) 

{

    echo "<tr>";

    echo "<td>" . $row['item_id'] ."</td>";

    echo "<td>" . $row['ITEM_NAME'] . "</td>";

    echo "<td>" . $row['suggested_qty'] . "</td>";

    echo "<td><input type='text' name='editedvalues[]' value='" . $row['suggested_qty'] . "' /></td>";

    echo "<td>total</td>";

    echo "</tr>";

}

?>


</table>

</form>

您应该在输入字段中添加一个javascript onchange侦听器,以计算每一行的总价并将其显示给用户。


查看完整回答
反对 回复 2021-05-07
  • 1 回答
  • 0 关注
  • 97 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信