I am hoping someone could help me with a problem I have building a PayPal button for a third party cart.
I need to increment each input name in my form so that each item_name and amount is numbered like this......
Code: Select all
<input type="hidden" name="item_name_01" value="item01">
<input type="hidden" name="amount_01" value="amount01">
<input type="hidden" name="item_name_02" value="item02">
<input type="hidden" name="amount_02" value="amount02">
<input type="hidden" name="item_name_03" value="item03">
<input type="hidden" name="amount_03" value="amount03">Here is my attempt so far which sort of works. It increments the item_names and amounts but only returns the first
item in the cart for each item_name etc..
My query to get the items.....
Code: Select all
$result8 = @mysql_query("SELECT * FROM orders INNER JOIN products ON orders.productID = products.productID INNER JOIN images ON orders.imageID = images.imageID
INNER JOIN users ON orders.userID = users.userID WHERE orders.orderNo = '$orderNo' ORDER BY orders.orderID DESC");
$confirmedButton = @mysql_fetch_array($result8);Code: Select all
<form target="paypal" name="paypal" id="paypal" method="post" action="https://www.paypal.com/cgi-bin/webscr">
<input type="image" src="Images/Buttons/button_paynow.gif" alt="Pay Now" title="Pay Now">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="sales@mywebsite.co.uk">
<?php
$result = mysql_query("SELECT COUNT(*) FROM orders WHERE orderNO = '$confirmedOrderNo' AND userID = '$userID' ");
$row = mysql_fetch_row($result);
$numrows = $row[0];
do{
for($i = 1; $i <= $numrows; $i++){
?>
<input type="hidden" name="item_name_<?php echo $i ?>" value="<?php echo $confirmedButton['title']; ?>, <?php echo $confirmedButton['productName']; ?>">
<input type="hidden" name="amount_<?php echo $i ?>" value="<?php echo $confirmedButton['productPrice']; ?>">
<?php }while($confirmedButton = @mysql_fetch_array($result8));
}while($row = mysql_fetch_row($result));
?>
<input type="hidden" name="currency_code" value="GBP">
</form>Code: Select all
<form target="paypal" name="paypal" id="paypal" method="post" action="https://www.paypal.com/cgi-bin/webscr">
<input type="image" src="Images/Buttons/button_paynow.gif" alt="Pay Now" title="Pay Now">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="sales@mywebsite.co.uk">
<input type="hidden" name="item_name_1" value="The Roof, 9"x6" Print, 12"x10" mount.">
<input type="hidden" name="amount_1" value="10.00">
<input type="hidden" name="item_name_2" value="The Roof, 9"x6" Print, 12"x10" mount.">
<input type="hidden" name="amount_2" value="10.00">
<input type="hidden" name="item_name_3" value="The Roof, 9"x6" Print, 12"x10" mount.">
<input type="hidden" name="amount_3" value="10.00">
<input type="hidden" name="currency_code" value="GBP">
</form>should be 3 different items.
I hope I have explained this okay. Post if I havn't and I'll try to explain it better.
Hopefully someone can help.
Thanks. Paul