View Single Post
Old 01-10-2008, 06:49 PM   #6 (permalink)
SOCK
The Acquainted
 
Join Date: Nov 2007
Posts: 154
Thanks: 31
SOCK is on a distinguished road
Default

You need to use an ALIAS on that result, e.g.
Code:
SELECT SUM(`rate`) / COUNT(`rate`) AS average_rate from `rate`
Refer to the alias average_rate in your PHP code, i.e. $mas['average_rate'].

This is why we ask you to be more specific; the query xenon provided by example works fine as-is in MySQL, but not if you want to return the value in PHP.

I would also suggest, if you're retrieving only one column from a resultset, use mysql_result() instead of one of the mysql_fetch_* functions. You don't need an array, there is only a single row and single column result output.
__________________
I reject your reality, and substitute my own.
SOCK is offline  
Reply With Quote