I’m working on my project now but I have encountered some problems :/
My method is supposed to gather information from the database and then count the average. This is what I get so far:
Rate: 4
Food_Food_ID: 2
------------
Rate: 4
Food_Food_ID: 2
------------
Rate: 2
Food_Food_ID: 2
------------
Rate: 12
Food_Food_ID: 2
------------
Rate: 5
Food_Food_ID: 4
------------
Rate: 10
Food_Food_ID: 4
------------
Average: 6.166666666666667
(This is the average of all the Rates :/ )
But I’m trying to get:
Rate: 22
Food_Food_ID: 2
Average: 5.5
------------
Rate: 15
Food_Food_ID: 2
Average: 7.5
------------
It should add all of the rating and then count the average of the rating. I hope I explained it good 🙂
Here is the code: http://pastebin.com/zUdF9HwF
First time posting here, hope I did okey. And thanks for the help 😀
This is what SQL was invented for, see:
No loops, no counting, just one SQL and you get the results.