Dear All,
If anybody can help a poor simpleton newbie I would really appreciate it.
It maybe the monday syndrome but nothing i do works!

I have a multi dimensional array made in the following manner.


part_no = varchar part number
po_id = varchar order number
weeky = week number
qnty = int quantity of items

I would like to retrieve the total number of qnty per part_no for each weeky

Please help!

thankyou in advance.

6 Years
Discussion Span
Last Post by prithivi

Have you already tried count($datasq["$part_no"]) ?

Also, if $part_no is a number, there is no need for double quotation marks. You can just call it by numeric association.


thanks for the replies.
sorry dudes i may not have been clear and clarity is what i need!
the idea is that there may be 10 different part numbers and i need a cumulative count for each distinct part number.
so kinda...
foreach part number [distinct] get total quantity for week
it might just be easier to do this in sql.
This is starting to pickle my brain.


Let me see if i got this straight:

What you want to do is accumulate the weeky count for each week in all the part numbers? As to see how many parts per week you have?


Maybe you have already tried this or maybe I still do not understand your question, but I will post this anyway, you know, just in case...

foreach($datasq as $key=>$val){
  echo "For part no". $key. "<br />";
  echo "qnty is: ". $val['qnty'];

EDIT: @Nichito sorry mate. did not see that.

Edited by kekkaishi: n/a


Thanks for posting.
The function returns the qnty for each item brilliantly. thankyou.
However, the count for each item needs to be cumulative.


part qnty
red 3
blue 2
red 16
orange 1
blue 90
blue 5

red = 19
blue = 97
orange = 1

i just cannot get my head around how to approach the problem.



that is EXACTLY correct.

Even t point me in the right direction would be appreciated.
should i even be using arrays? or would an SQL query do the job?


you can do this perfectly in php, though you'd have to create an array for the different weeky values. Better do this with a sql query, using sum(column) and a group by clause.


thanks Nichito

i was looking at trying to do it that way but the sql already involves an inner join.
thought arrays may be simpler. DOH!

I will post what i end up doing.

Thanks again.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.