Calculate avg age of multiple users?!?!
I'm trying to figure ot the avareage age of all users in a certain group.
This is how I calculate 1 user:
PHP Code:
$sql="SELECT * FROM ".$prefix."_users WHERE group = 1";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
$birthday = $row['birthday']; // 1970-05-08 //
list($year,$month,$day) = explode("-",$birthday);
$year_diff = date("Y") - $year;
$month_diff = date("m") - $month;
$day_diff = date("d") - $day;
echo 'Age: '.$year_diff;
}
As you can see I calculate the age outside the query... I think I have to doit within the query...
Any help is apreciated...
Thanks in advance ;-)