I want to use the avg() function. I have a column named "blue". In this column are various numbers of 1-9. I want to get the average number for a particular group.
I'm using the code below but it doesn't work. Can someone show me what I am doing wrong? Thanks
$result = mysql_query("SELECT avg(blue) FROM table_name WHERE user_id='$user_id'") or die (mysql_error());
while ($row = mysql_fetch_array($result)) {
$blue= $row["blue"];
}
echo "$blue";