I'm sure this is pretty simple and I am just totally messing it up. I'm using mysql with php. I have a column named "ranking". In this column I have numbers ranging from 1-4. I want to get the average number from a certain group.
Example: there are three entries in this column and the three individual entries are the numeral "4". The total would equal 12 but the average would still be "4".
Below is a sample of the code I am trying to use but messing up with. Can anyone show me where I am going wrong? I know this is probably very simple but I can't get it to work. Thanks in advance.
Lord Rogaine
$sql= mysql_query("SELECT avg(ranking) from table_name where user_id ='$user_id'");
echo "$ranking";