I know how to solve this in a non-elegant, non-practical way, meaning sending requests, one by one, for each value in specified column that is shared and then handle all data from that specific output, then, do the same for another value, etc., etc. But I was wondering if someone out there thought of an ELEGANT and PRACTICAL way, which would mean all this is handled by one single PHP function.
Basically, I have this table:
location | title | description | quantity
============|===========|=============|==========
shelf | apple | red | 2
drawer | banana | yellow | 4
shelf | kiwi | green | 2
cupboard | lemon | yellow | 1
fridge | melon | orange | 3
drawer | peach | orange | 1
And what I eventually want is to create a jQuery pie chart that tells me what percentage of title
is in each location
. But before that I need a function that outputs shelf => 4
(2+2), drawer => 5
(4+1), etc., etc.
So, the question is, is there an elegant, practical way to make this happen? Meaning, to retrieve all rows but group together all data by location and, then, sum each location's quantity to be later on turned into a percentage for the pie chart?
Thanks!