View Single Post
Old 12-27-2012, 07:37 PM   PM User | #2
Redcoder
Regular Coder

 
Redcoder's Avatar
 
Join Date: May 2012
Location: /dev/couch
Posts: 309
Thanks: 2
Thanked 46 Times in 45 Posts
Redcoder has a little shameless behaviour in the past
Use foreach:
PHP Code:
foreach($array as $value)
{

       
$id_quantity_pair explode("-"$value); // Uses Hyphen(-) as delimiter to separate product ID from its quantity
        
$product_id $id_quantity_pair[0]; // Get the product ID
        
$product_quantity $id_quantity_pair[1];   

//Do calculation to get Total Price for this Item

//E.g 
//Get price from DB in $price using Product ID like $product_array = mysqli_fetch_array(mysqli_query($db, "SELECT * FROM products WHERE product_id = $product_id")); $price = $product_array['price'];
$total_price[] = $price $product_quantity;



__________________
For professional Hosting and Web design.....


NetEssentials.co.uk

Last edited by Redcoder; 12-27-2012 at 07:46 PM..
Redcoder is offline   Reply With Quote