How is this possible

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stebut05
Forum Commoner
Posts: 35
Joined: Wed Sep 21, 2005 9:29 am
Location: Liverpool, UK

How is this possible

Post by stebut05 »

Hi all,

I hope someone can help me with this problem. I have a query that selects shipping details from a customer account. The i have a second query to count the weight of all the products in the shipping query. How do i count all the weights of products and display the result??

Shipping query:

Code: Select all

$query = "SELECT * FROM Shipping, Customers, Orders, Delivery_Zones 
WHERE Delivery_Zones.zone_id = Orders.delivery_zone AND Shipping.order_id = Orders.order_id AND Customers.customer_id = Orders.customer_id AND dispatch_date = '$dispatchdate'";
As you can see there can be more than one set of results for this query


Product weight query:
$order_id = $rows['order_id'];

Code: Select all

$query2 = "SELECT * FROM Product_Description, Order_Details 
WHERE Product_Description.product_id = Order_Details.product_id AND Order_Details.order_id = '$order_id'";
The finally my script to count the weight of products

Code: Select all

$weight = $rows2['product_weight']; 
$totalweight =+ $weight; 
echo $totalweight;
I really appreciate any help, advice given in advance.

Regards,

Steven
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: How is this possible

Post by alex.barylski »

stebut05 wrote:Hi all,

I hope someone can help me with this problem. I have a query that selects shipping details from a customer account. The i have a second query to count the weight of all the products in the shipping query. How do i count all the weights of products and display the result??

Shipping query:

Code: Select all

$query = "SELECT * FROM Shipping, Customers, Orders, Delivery_Zones 
WHERE Delivery_Zones.zone_id = Orders.delivery_zone AND Shipping.order_id = Orders.order_id AND Customers.customer_id = Orders.customer_id AND dispatch_date = '$dispatchdate'";
As you can see there can be more than one set of results for this query


Product weight query:
$order_id = $rows['order_id'];

Code: Select all

$query2 = "SELECT * FROM Product_Description, Order_Details 
WHERE Product_Description.product_id = Order_Details.product_id AND Order_Details.order_id = '$order_id'";
The finally my script to count the weight of products

Code: Select all

$weight = $rows2['product_weight']; 
$totalweight =+ $weight; 
echo $totalweight;
I really appreciate any help, advice given in advance.

Regards,

Steven
You probably want to look into http://www.sql-tutorial.net/SQL-SUM.asp
Post Reply