Jump to content

Recommended Posts

hi all ...

 

I have a list generated from mysql with products what have not delivered to customers.

 

how can i tell to php or mysql  ??? to cumulate the items with the same id and to calculate the quantity of the items ?

exemple:

 

Nr.    ID      The product                        UM    QTY    ord nr

1  88  Antene pentru plase volei  per  2  767762

2 88 Antene pentru plase volei  per 1 791688

3 305 Aparat de măsurat detenţa  buc 1 264954

4 305 Aparat de măsurat detenţa  buc 2 659272

5 286 Aparat de ramat HAMMER buc 2 767762

6 286 Aparat de ramat HAMMER buc 1 419495

7 286 Aparat de ramat HAMMER buc 1 430298

8 286 Aparat de ramat HAMMER buc 1 219941

9 286 Aparat de ramat HAMMER buc 7 825287

10 286 Aparat de ramat HAMMER buc 1 791688

 

and i want to show something like:

1  88  Antene pentru plase volei  per  3  767762

2 305 Aparat de măsurat detenţa  buc 3 264954

35 286 Aparat de ramat HAMMER buc 13 767762

 

the code what i use now:

 

$query = "select prod_com.pr_id, prod_com.ord_nr, prod_com.cmd_id, prod_com.pr_qty, products.pr_name, products.pr_desc, products.pr_um, products.pr_price from prod_com, products WHERE prod_com.pr_id=products.pr_id and prod_com.pr_id=prod_com.pr_id and prod_com.pr_date_deliv is NULL ORDER BY products.pr_name";

 

thanks!

The solution is:

$query = "SELECT prod_com.pr_id, prod_com.ord_nr, prod_com.cmd_id, prod_com.pr_qty, sum(prod_com.pr_qty) AS total_quantity FROM prod_com GROUP BY prod_com.pr_id";

 

the reference:

http://www.thescripts.com/forum/thread647763.html

 

Very cool thing !

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.