The line saying <?php while ($row = $arne->fetch()) { ?>
Seems to be working totally fine in localhost server with:
Picture: localhost setup
<?php
$arne = $db->query("SELECT *, AVG(correct_answers) AS average FROM result r, quiz q WHERE r.quiz_id=q.id GROUP BY quiz_id ORDER BY average");
?>
<h1>Average Score</h1>
<div id="table-wrapper">
<div id="table-scroll">
<table>
<tr>
<th>Quiz</th>
<th>Result</th>
<th>Questions</th>
</tr>
<?php while ($row = $arne->fetch()) { ?>
<tr>
<td><a href="/quiz/<?=$row["quiz_id"]?>"><?=$row["name"]?></a></td>
<td><?=floor($row["average"]*100 / $row["question_count"])?></td>
<td><?=$row["question_count"]?></td>
</tr>
<?php } ?>
</table>
</div>
</div>
But when using it on a webserver: Picture: webserver setup
I get the error:
Fatal error: Uncaught Error: Call to a member function fetch() on boolean in /var/www/html/php/pages/statistics.php:15 Stack trace: #0 /var/www/html/php/index.php(82): include() #1 {main} thrown in /var/www/html/php/pages/statistics.php on line 15
Line 15 is not line 15, but the line containing:
<?php while ($row = $arne->fetch()) { ?>
Thanks for help!