Hi all,
I know how to do this in normal php, but putting into oo php (which i'm new to) is proving to be difficult and i'm struggling to get my head around it. I'm wondering if anyone could help me.
Basically i have a table called ground which very simply looks like this:
id name rating
1 test1 5
2 test2 2
3 test3 4
etc etc.
What i want to do is to work out the average of the rating column.
At the moment on the page i have
<?php
$rating = new Ground();
$rating = $this->getRating();
?>
then in my ground class
public function getRating()
{
$sql = "SELECT SUM(rating) AS average FROM ground";
$this->executeQuery($sql);
$this->getRowCount(); // returns number of rows
// here i need to work out the average!
}
I've tried a number of things in the class to try and work out the average, but for some reason i can't get the sum value. I admit the code above maybe and probably is riddled with errors, go easy on me am still new to the OO world! Any help would be greatly appreciated,
Thanks,
pb1uk