I am currently using: mysql_fetch_array to receive data... but it's just not right. If one item is added to the cart.. things are just fine.. it lists Item A, Quantity and Price and goes to checkout. BUT.. if I add a second item.. only Item A is submitted to Paypal... as if I never ordered Item B. I have done tests by the echo command of the particular row... and know that the contents I want are accessible and are a true mysql resource. There must be something incredibly stupid that I am missing or am more out of touch than I thought.
Please consider the following codes:
$result = mysql_db_query($dbname, "SELECT details.item, details.price, cart.cQuantity, details.special, details.serial FROM cart, details WHERE cart.pID = details.serial AND cart.id = ".$_SESSION[$site_session.'id']." AND details.pAvailable = 1 ORDER BY details.item");
$i=0;
$row = mysql_fetch_array($result);
($num_rows = mysql_num_rows($result));
for($i=0; $i < $num_rows; $i++){
$myitem[$i] = $row['item'];
$sprice[$i] = $row['price'];
$cQuantity[$i] = $row['cQuantity'];
if($row['special'] == 1) {
$result_special = mysql_db_query($dbname, "SELECT item, price FROM specials WHERE serial = ".$row["serial"]);
$row_special = mysql_fetch_array($result_special);
$myitem[$i] = $row_special['item'];
$sprice[$i] = $row_special['price'];
++$i;
}
}
This is to retrieve the values from the database... so that i can then echo their values in the submit form that Paypal requires with their values.
Here is good ol' Paypal's form to be populated:
<form target="paypal" action="https://www.sandbox.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="myemail@service.com">
<!-- Begin First Item -->
<input type="hidden" name="quantity_1" value="<?php echo$cQuantity[1]; ?>">
<input type="hidden" name="item_name_1" value="<?php echo$myitem[1]; ?>">
<input type="hidden" name="item_number_1" value="">
<input type="hidden" name="amount_1" value="<?php echo$sprice[1]; ?>">
<input type="hidden" name="shipping_1" value="0.01">
<input type="hidden" name="shipping2_1" value="0.01">
<input type="hidden" name="handling_1" value="0.01">
<input type="hidden" name="tax_1" value="0.01">
<input type="hidden" name="on0_1" value="Option Name1 A">
<input type="hidden" name="os0_1" value="Option Selection1 A">
<input type="hidden" name="on1_1" value="Option Name2 A">
<input type="hidden" name="os1_1" value="Option Selection2 A">
<!-- End First Item -->
<!-- Begin Second Item -->
<input type="hidden" name="quantity_2" value="<?php echo$cQuantity[2]; ?>">
<input type="hidden" name="item_name_2" value="<?php echo$myitem[2]; ?>">
<input type="hidden" name="item_number_2" value="">
<input type="hidden" name="amount_2" value="<?php echo$sprice[2]; ?>">
<input type="hidden" name="shipping_2" value="0.01">
<input type="hidden" name="shipping2_2" value="0.01">
<input type="hidden" name="handling_2" value="0.01">
<input type="hidden" name="tax_2" value="0.01">
<input type="hidden" name="on0_2" value="Option Name1 A">
<input type="hidden" name="os0_2" value="Option Name2 A">
<input type="hidden" name="on1_2" value="Option Name2 A">
<input type="hidden" name="os1_2" value="Option Selection2 A">
<!-- End Second Item -->
When I run it and view the source... this is what the above form generated:
<form target="paypal" action="https://www.sandbox.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="myemail@service.com">
<!-- Begin First Item -->
<input type="hidden" name="quantity_1" value="1">
<input type="hidden" name="item_name_1" value="Ohiomans Product A">
<input type="hidden" name="item_number_1" value="">
<input type="hidden" name="amount_1" value="9.95">
<input type="hidden" name="shipping_1" value="0.01">
<input type="hidden" name="shipping2_1" value="0.01">
<input type="hidden" name="handling_1" value="0.01">
<input type="hidden" name="tax_1" value="0.01">
<input type="hidden" name="on0_1" value="Option Name1 A">
<input type="hidden" name="os0_1" value="Option Selection1 A">
<input type="hidden" name="on1_1" value="Option Name2 A">
<input type="hidden" name="os1_1" value="Option Selection2 A">
<!-- End First Item -->
<!-- Begin Second Item -->
<input type="hidden" name="quantity_2" value="">
<input type="hidden" name="item_name_2" value="">
<input type="hidden" name="item_number_2" value="">
<input type="hidden" name="amount_2" value="">
<input type="hidden" name="shipping_2" value="0.01">
<input type="hidden" name="shipping2_2" value="0.01">
<input type="hidden" name="handling_2" value="0.01">
<input type="hidden" name="tax_2" value="0.01">
<input type="hidden" name="on0_2" value="Option Name1 A">
<input type="hidden" name="os0_2" value="Option Name2 A">
<input type="hidden" name="on1_2" value="Option Name2 A">
<input type="hidden" name="os1_2" value="Option Selection2 A">
<!-- End Second Item -->
See.. second item.. no value.
I would appreciate sample coding to look at or suggestions.
Thank you much,
Calvin
P.S. As the coding will suggest.. I am only interested in the quantity, item name and price.