Hi,
I'm actually drafting a MySQL query to be fed into Jasper Reports, and since I can no longer manipulate the resulting data in PHP as it will automatically be translated into a chart by jasper, I need my mysql statement to be able to generate what I need on its own.
Let me start with the table structure of table `package_price`:
(this is not my actual table, just for sample purposes)
fields: id, package_id, price
*package_id is not unique
Now, the situation is, on my website I have checkboxes (e.g. Package1, Package2, Package3, ALL) which, depending on what packages were chosen, should display the total price by package. The ALL option does not mean checking all packages...it is an option on its own..which means that, if Package1 and ALL are chosen, it should display the total price of all rows where package_id = Package1 ...and... the total price of all rows.
Example:
Package1 - 2345
All - 78904
Keep in mind that checkboxes on PHP are stored in an array...so, if I choose Package1 and ALL, given that my checkbox variable name is package...my array should be: package[0] = Package1, package[1] = ALL.
My question is, how do I translate it to a mysql statement? If, without the ALL option, my mysql/php statement should be: (pls don't mind the syntax)
foreach($package as $p){
SELECT SUM(price) from package_price where package_ID = $p GROUP BY package_ID;
}
With the ALL option, how do I incorporate everything into one mysql query statement?
I hope I explained my situation clear enough.
Thanks,
michelle