Look at code below:
<?php
$output += "
<table border='1'>
<tr>
<th>Session ID</th>
<th>TeacherUsername</th>
<th>Teacher Name</th>
<th>Module Number</th>
<th>Module Name</th>
<th>Course ID</th>
<th>Course Name</th>
<th>Year</th>
<th>Student Username</th>
<th>Student Name</th>
<th>Mark</th>
<th>Grade</th>
</tr>
";
$total = 0;
$count = 0;
while ($row = mysql_fetch_array($result)) {
$count++;
$total += $row['Mark'];
$output += "
<tr>
<td>{$row['SessionId']}</td>
<td>{$row['TeacherUsername']}</td>
<td>{$row['TeacherForename']} {$row['TeacherSurname']}</td>
<td>{$row['ModuleId']}</td>
<td>{$row['ModuleName']}</td>
<td>{$row['CourseId']}</td>
<td>{$row['CourseName']}</td>
<td>{$row['Year']}</td>
<td>{$row['StudentUsername']}</td>
<td>{$row['StudentForename']} {$row['StudentSurname']}</td>
<td>{$row['Mark']}</td>
<td>{$row['Grade']}</td>
</tr>";
}
$output += " </table>";
$average = (int)($total/$count);
echo "<p>Average Mark: $average</p>";
echo $output;
?>
For some strange reason it does not echo $output (which is at bottom of the code) properly. It is suppose to output the table but instead it echos 0, why does it output 0?
Don’t use javascript’s, plus but use php’s dot
But you have to also define
$outputfirst before using.=.so in result: