我正在努力使用户可以将多个产品添加到Paypal结帐。 Paypal表单中的name =“item_name_1”必须递增1才能将其添加到购物车中。所以我想在每次while循环到达结尾时向变量($ number)添加1,但它不起作用。
while循环
//for paypal order number
$number = 0;
while($row = oci_fetch_assoc($runquery)) {
$number = $number + 1;
$prodid = $row['PRODUCT_ID'];
$price = $row['PRICE'];
$image = $row['IMAGEID'];
$prodname = $row['NAME'];
$stallname = $row['STALL_NAME'];
$quantity = $row['PRODUCTQUANTITY'];
$day = $row['DAY'];
$time = $row['TIME_CHOICE'];
$total = $row['TOTALPRICE'];
$subtotal = $price * $quantity;
echo ' <tbody>
<tr>';
echo '<td> <img src="' . $image . '" height="50" width="50"/></td>';
echo '<td>' . $prodname . '</td>';
echo '<td>' . $stallname . '</td>';
echo '<td> ' . $quantity . '</td>';
echo '<td>£' . $price . '</td>';
echo '<td>£' . $subtotal . '</td>';
echo' </tr>';
//increments number for paypal orders
echo'
</tbody>
<thead>
<tr>
<th>Clear Order</th>
<th></th>
<th>Collection Day</th>
<th>Collection Time</th>
<th>Total</th>
<th>Pay</th>
</tr>
</thead>
<tbody>
<td><form method="post" action="clearorder.php"><input type="submit" name="clearorder" value="Clear" /></form></td>
<td></td>';
echo '<td>' .$day . '</td>';
echo '<td>' .$time . '</td>';
echo '<td>£' .$total . '</td>';
echo'
Paypal form
<form action="https://www.paypal.com/uk/cgi-bin/webscr" method="post">
<td>
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="email"';
echo '<input type="hidden" name="item_name_' . $number . '" value="' . $prodname . '">';
echo'<input type="hidden" name="quantity_' . $number . '" value="' . $quantity . '">';
echo '<input type="hidden" name="amount_' . $number . ' value="' . $price . '">';
echo '<input type="hidden" name="currency_code" value="GBP">';
echo '<input type="hidden" name="upload" value="1">';
}
}
?>