如何在 PHP MySQL 或 javascript 中增加/删除产品的数量?或者如何在复选框中插入产品的数量值?
<form action="addtocart.php" method="post">
<table width="100%" cellspacing="20px">
<?php
include 'dbconnect.php';//for connection
$sql='select * from product';
$res = $dbconn->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
$res->execute();
$disp="<tr><th>Image</th><th>Product Name</th><th>Price</th><th>Add To Cart</th></tr>";
while($rs=$res->fetch())
{
if($rs['availableOnline']==1)
$isonline="Yes";
else
$isonline="No";
if($rs['availableInStore']==1)
$isstore="Yes";
else
$isstore="No";
$disp.="<tr>";
$disp.="<td><img src=".$rs['imageLink']." width=50 height=70></img></td>";
$disp.="<td>".$rs['name']."</td>";
$disp.="<td>$ ".$rs['price']."</td>";
$disp.="<td><input type=checkbox value=".$rs['idProduct']." name=items[] > Add Item</td></tr>";
$disp.="<tr><td> </td><td>Available Online : ".$isonline."</td><td>Available in Store :".$isstore."</td><td> </td></tr>";
}
echo $disp;
?>
<tr><td> </td><td><input type="submit" id="btnsubmit" value="Add To Cart" /></td></tr>
</table>
</form>