Hi all.
Wondering if anyone can shed some light!

I have a problem whereby I need to define the weight of a selection of
items in a shopping cart in order to calculate a shipping cost.
Basically I have 5 products (at the moment) which are of set weights.
What I want to do is add up the amount of items in the cart and multiply
by weight then determine what the shipping weight is. Once that is
determined I can calculate the shipping cost. My problem is arrays. I
dunno what I'm doing with them! I can return the weight of one item and
multiply that by the amount of items in the cart but need to figure out
how do then do it again for any more items and add them to the first
calculation. Here is my code:

function calculate_weight($items)
{
        global $weight;
        $conn = db_connect();
        $query = "select weight from products 
                                where catid = $catid";
        $result = @mysql_query($query);
        $weight = ($result*$items);
        return $weight;
}

Where $items is the number of items in the cart. $catid is the category
the products are in but maybe I need to use a different identifier. I
have another identifier called $itemCode which defines the actual item
which would probably be more reasonable?

Thoughts?
Regards,          

Steve Jackson
Web Developer
Viola Systems Ltd.
http://www.violasystems.com
[EMAIL PROTECTED]
Mobile +358 50 343 5159


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to