I want to calculate the Average value of all other columns grouping them by collegename. i.e RVCE with Average of all other columns, BMS with Average of all other columns and so on and display the value in HTML.
I have tried the following code in but it is returning me no values.
<?php
$hostname="localhost:8889";
$username="root";
$password="root";
$db = "rank";
$dbh = new PDO("MySQL:host=$hostname;dbname=$db", $username, $password);
foreach($dbh->query('SELECT collegename,AVG(campus)
FROM college
GROUP BY collegename') as $row) {
echo "<tr>";
echo "<td>" . $row['AVG(campus)'] . "</td>";
echo "</tr>";
}
?>