In the database "beans" i have a table "bags_o_beans" where each row represents a single bag, and columns named "bean_type" and "number_o_beans"
My teenage son is having several thousand hungry friends over in half an hour, and I'm stuck making the bean dip... I'm going to need 1 million beans of a single type to make the dip.
My goal, before I start cooking, is to filter from the following query:
SELECT bean_type, sum(number_o_beans) FROM bags_o_beans GROUP BY bean_type
...into an html table such that only 'bean types' with 'sum(number_of_beans)' greater than 1 million are displayed. I have tried inserting the following snippet into the table-generating php code, with no luck:
while ($row = @ mysql_fetch_row($result)) { foreach($row as $data) if ({sum(number_o_beans)} > (1000000)) print "\n\t<td> {$data} </td>"; print "\n</tr>"; }
Thanks ahead of time for your thoughts and recipes :) Grant
Are we doing your homework for you?
Why not just do this in your query?
SELECT bean_type, sum(number_o_beans)AS sum_beans FROM bags_o_beans GROUP BY bean_type HAVING sum_beans > 1000000
--
John Holmes
php|architect - The magazine for PHP professionals - http://www.phparch.com
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php