【发布时间】:2015-02-18 09:47:19
【问题描述】:
我正在编写一个程序,我正在使用 php 在表中从 mysql 打印我想在 jquery 的帮助下获取输入字段值如何使用 jquery 获取每个输入值。
<?php
$sql = "SELECT id, name, price, qty FROM appetisers";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
$quantity = $row["qty"];
if ($quantity == '' || $quantity == '0') {
$quantity = '1';
}
?>
<tr class="eachrow">
<td><?php echo $row["name"] ?></td>
<td class="price-amount">£ <?php echo $row["price"] ?></td>
<td><input type="text" name="amount" class="amount-type" value="<?php echo $quantity; ?>"/></td>
<td><a href="" class="add-cart">Add to cart</a></td>
</tr>
<?php }
}
?>
【问题讨论】: