<?php
include("config.php");
$cart=$_GET['cart'];
$numberofcart=$_GET['numberofcart'];
if ($cart) {
mysql_query("INSERT INTO trade (cart,price) values('$cart','150LE')");
}
?>
<form action="index.php" method="GET">
<input type="text" name="cart" />
<input type="text" name="numberofcart" />
<input type="submit" />
</form>
&#13;
在mysql中就像这样
id购物车价格
1笔150LE
2笔150LE
3笔150LE
答案 0 :(得分:0)
<?php
include("config.php");
$cart=$_POST['cart'];
$numberofcart=$_POST['numberofcart'];
$values ='';
if ($cart !=='' && $numberofcart !=='') {
for($i=0;$i<$numberofcart;$i++){
$values .= "('$cart','150LE'),";
}
$values = trim($values,',');
mysql_query("INSERT INTO trade (cart,price) values $values");// good to change connection code in file according to mysqli_* standards
}else{
echo "form field are required";
}
?>
<form action="index.php" method="POST">
<input type="text" name="cart" />
<input type="text" name="numberofcart" />
<input type="submit" />
</form>
实施例: - https://eval.in/694166