Re: [Newbie] Simple stats from mysql table data
| From: | Burhan Khalid | Date: | Tue, 18 May 2004 13:31:51 +0000 |
| Subject: | Re: [Newbie] Simple stats from mysql table data | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-186473@lists.php.net to get a copy of this message | ||
Vans Hallden wrote:
You need to fetch the results. http://www.php.net/mysql_fetch_assoc for example.Here is one way: (probably not the best)I was able to get almost everything working with your help. Thanks!!! :)I have one small problem remaining. With this code: $male_average_age = mysql_query("SELECT AVG(age) FROM my_database WHERE sex = 'M'"); ..I get a strange "Resource id#10" output. I can't figure out why. What am I missing?average ages for male/female respondents (database column 'age')SELECT AVG(age) FROM tablename WHERE sex = 'male'; SELECT AVG(age) FROM tablename WHERE sex = 'female';