bineye Posted April 6, 2011 Posted April 6, 2011 (edited) $query=mysql_query("SELECT teamid, AVG(rating) FROM players WHERE teamid=$getteam", $c) or die(mysql_error()); $result=mysql_fetch_assoc($query); Team Rating: ".$result." Hi, my problem is that $result returns "Array" instead of an average value of the column "rating". Any ideas why this is happening? Thanks. Edited April 6, 2011 by bineye add tags Quote
Nickson Posted April 6, 2011 Posted April 6, 2011 mysql_fetch_assoc() returns an array where each key is a field out of the database-query as you named them via your select query. You would have to use $result['NAME_OF_FIELD'] References: http://be2.php.net/mysql_fetch_assoc Quote
galdikas Posted April 8, 2011 Posted April 8, 2011 alternatively you can extract($result); Team rating: $name_of_column_in_db; Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.