+ 2
PHP [mysql ] How to display average of data from database into website
I have a table in database called appinfo where I have a column called star where I have data of rating values from 1-5. I want to show average rating on the Web page using php mysql. sample data of star 2 5 5 4
2 Réponses
+ 3
Just pull all the data from the database and calculate the averages like normal.
For mean just add up the numbers and divide it by the number count.
+ 1
I assume you have the php connection to the database already.
query: SELECT AVG(`star`) AS `averageRating` FROM `ratings`
your return will be 1 row with 1 field names averageRating.