please please help
i have built a shopping cart which works, my problem is passing multiple items to paypal. i can send one item no problem but when i try to send 2 or more items paypal shows 14 items called array.
please look at my code any help greatly appreciated.
i am sure it is a problem with the while and for loops not sending the correct info.
<html>
<body>
<form target= "paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value ="me@me.co.uk">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="shipping" value="4.95">
<input type="hidden" name="shipping2" value="0.00">
<input type="image" src="http://www.paypal.com/en_GB/i/btn/x-click-but02.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<form>
<?php
session_start();
//connect to database
$mysqli = mysqli_connect("me", "me", "me", "me");
$display_block = "<td align=\"center\"><h1>Your Shopping Cart</h1>";
//check for cart items based on user session id
$get_cart_sql = "SELECT st.id, si.item_title, si.item_price, st.sel_item_qty, st.sel_item_size, item_image, st.sel_item_color FROM store_shoppertrack AS st LEFT JOIN store_items AS si ON si.id = st.sel_item_id WHERE session_id = '".$_COOKIE["PHPSESSID"]."'";
$get_cart_res = mysqli_query($mysqli, $get_cart_sql) or die(mysqli_error($mysqli));
if (mysqli_num_rows($get_cart_res) < 1) {
//print message
$display_block .= "<p>You have no items in your cart.
Please <a href=\"index.html\">continue to shop</a>!</p>";
} else {
//get info and build cart display
$display_block .= "
<table border=\10 width=\"76%\"bgcolor=\"#FFCCFF\"<td align=\"center\">
<tr>
<th>Image</th>
<th>Title</th>
<th>Size</th>
<th>Color</th>
<th>Price</th>
<th>Qty</th>
<th>Total Price</th>
<th>Action</th>
</tr>";
while ($cart_info = mysqli_fetch_array($get_cart_res)) {
$id = $cart_info['id'];
$item_title = stripslashes($cart_info['item_title']);
$item_price = $cart_info['item_price'];
$item_qty = $cart_info['sel_item_qty'];
$item_color = $cart_info['sel_item_color'];
$item_size = $cart_info['sel_item_size'];
$total_price = sprintf("%.02f", $item_price * $item_qty);
$Sub_Total = sprintf("%.02f", $total_price)+($Sub_Total);
$item_image = $cart_info['item_image'];
//this i believe is the problem
for($i=0; $i < count($get_cart_res); $i++){
$val = $i + 1;
echo "<input type=\"hidden\" name=\"quantity_$val\" value=\"$item_qty\">";
echo "<input type=\"hidden\" name=\"item_name_$val\" value=\"$item_title\">";
echo "<input type=\"hidden\" name=\"amount_$val\" value=\"$item_price\">";
}
}
$display_block .= "
<tr>
<td align=\"center\"><img src=\"".$item_image."\"/></td>
<td align=\"center\">$item_title <br></td>
<td align=\"center\">$item_size <br></td>
<td align=\"center\">$item_color <br></td>
<td align=\"center\">£ $item_price <br></td>
<td align=\"center\">$item_qty <br></td>
<td align=\"center\">£ $total_price</td>
<td align=\"center\"><a href=\"removefromcart.php?id=".$id."\">remove</a></td>
</tr>";
}
{
$display_block .= "
<tr>
<th><td align=\"right\"><strong>Sub Total</strong></th>
<td align=\"right\">£ $Sub_Total</td>
</td>";
$display_block .= "</table>";
}
?>
<title>My Store</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
h1,h2,h3,h4,h5,h6 {
font-family: Palatino Linotype;
}
h1 {
font-size: 24px;
color: #FF99FF;
text-align: center;
}
body {
background-image: url(images/heart4.jpg);
}
-->
</style></head>
<p align="center"><img src="images/sensual.jpg" width="520" height="104"></p>
<p align="center"><?php echo $display_block; ?></p>
<p align="center"> Free Delivery on all orders over £100</p>
<form name="form1" method="post" action="index.html">
<label>
<div align="center">
<input type="submit" name="Submit" value="Continue Shopping">
</div>
</label>
</form>
<p> </p>
<p>
</p>
</body>
</html>