Hello, i attempting to edit an online payment form to connect to MySQl, i have managed to get everyting working up until the payment page. The problem i am having is sending the cart contents via encrytion to the server. When there is one product, there are no issues. If there is more than one product in the cart, only the last product is sent through. My code to connect to the database is;
foreach($_SESSION['cart'] as $product_id => $quantity) {
$query = sprintf("SELECT * FROM all_products WHERE part_number = '%s';",$product_id);
$result = mysql_query($query)or die(mysql_error());
$num = mysql_num_rows($result);
if(mysql_num_rows($result) > 0) {
list($id, $part_number, $price) = mysql_fetch_row($result);
$line_cost = $price * $quantity;
$total = $total + $line_cost;
}}
The template that i am using builds the cart like so;
$sngTotal=0.0;
$strThisEntry=$strCart;
$strBasket="";
$iBasketItems=0;
while (strlen($strThisEntry)>0) {
// Add another item to our Form basket
$iBasketItems=$iBasketItems+1;
$total=$total + $quantity * $product_id;
$strBasket=$strBasket . ":" . $product_id . ":" . $quantity;
$strBasket=$strBasket . ":" . number_format($price,2); /** Item price **/
$strBasket=$strBasket . ":" . number_format($price*$quantity,2); /** Line total **/
// Move to the next cart entry, if there is one
$pos=strpos($strThisEntry,",");
if ($pos==0)
$strThisEntry="";
else
$strThisEntry=substr($strThisEntry,strpos($strThisEntry,",")+1);
}
The code from the template has got me completely confused and any help to fix this would be greatly appreciated.