On Thu, 5 Aug 2004 17:26:05 -0500, Grant Listhandle <[EMAIL PROTECTED]> wrote:
> 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

Use a column alias:

SELECT bean_type, sum(number_o_beans) AS total_number_of_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))

if($row['total_number_of_beans']) > 1000000)

> print "\n\t<td> {$data} </td>";
> print "\n</tr>";
> }
> 
> Thanks ahead of time for your thoughts and recipes :)
> Grant
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> !DSPAM:4112b26a148642019194572!
> 
> 


-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to