Thank you all for your replies. I really appreciate it. I did add a remove button to each item that any customer would choose from the list. but I still have a problem with the code itself. I didn't wirte the code as I am not an expert with php, this is why I am seeking help. when I click remove , it does remove the entry but when I add another item it gives me an empty entry and it miss the calculation. I am going to post the code so you will have a look at it, and if someone can edit it to get it work correctly, I will be really gratefull to him. and if not, is it possible for someone to write another code from the begining to make an order form like the one on the website ? a better code I mean that allow customers to remove any item they choose from the list. will be waiting for answers with patience. thanks in advance for everyone.
here's the current code:
<?
if($_POST['AddToCart'] && $_POST["ProductName"] || $_SESSION['CustomerOrder']){
if( $_POST["ProductName"] ){
$Order = array();
$ShoppingSession = array();
$IdProduct = $_POST['IdProduct'];
$ProductName = $_POST['ProductName'];
$Size = $_POST['Size'];
$Quantity = $_POST['Quantity'];
$ProductPrice = ($_POST['ProductPrice']) ;
$Totalprice = ( $Quantity * $ProductPrice) ;
$OrderPrice = ( $_SESSION['OrderPrice'] + $Totalprice);
$_SESSION['OrderPrice'] = $OrderPrice;
$CustomerOrder = $_SESSION['CustomerOrder'].'--'.$IdProduct.'|'.$ProductName.'|'.$Size.'|'.$Quantity.'|'.$ProductPrice.'|'.$Totalprice.'|'.$OrderPrice;
$CustomerOrder = trim($CustomerOrder,'--');
$_SESSION['CustomerOrder'] = $CustomerOrder;
// echo $CustomerOrder;
$CustomerOrderArray = split('--',$CustomerOrder);
}else{
$CustomerOrder = $_SESSION['CustomerOrder'] ;
$CustomerOrder = trim($CustomerOrder,'--');
$CustomerOrderArray = split('--',$CustomerOrder);
}
if($_REQUEST['r']) // this is the code of the remove button which doesn't work
$OrderPrice = ( $_SESSION['OrderPrice'] -$toRemove);s
$toRemove = ($_REQUEST['productPrice'])*($_REQUEST['quantity']);
$CustomerOrderArray = split('--',$CustomerOrder);
$CustomerOrderArray[$_REQUEST['IdShopping']]='';
$CustomerOrder = '';
foreach($CustomerOrderArray as $ke=>$val){
$CustomerOrder .= '--'.$val;
}
$_SESSION['CustomerOrder']=$CustomerOrder ;
$CustomerOrder = str_replace('----','',$CustomerOrder);
$CustomerOrder = trim($CustomerOrder,'--');
$CustomerOrderArray = split('--',$CustomerOrder);
}
if ( $CustomerOrder){
?>