karena kamu fetch data dari database kamu tidak bisa pakai array_sum, tapi dengan penjumlahan biasa seperti:
| <?php |
| $total = 0; |
| while($r=mysql_fetch_array($q)) |
| { |
| echo"<tr>"; |
| echo"<td>" . $no . "</td>"; |
| echo"<td width=15% >" .$r['kode_mk']."</td>"; |
| echo"<td width=100%>".$r['mk']."</td>"; |
| echo"<td><center>" .$r['sks']."</center></td>"; |
| echo"<td><center>" .$r['grade']."</center></td>"; |
| echo"<td><center>" .$r['NxB']."</center></td>"; |
| echo"</tr>"; |
| $total += $r['NxB']; |
| $no++; |
| } |
| echo"</table></br>"; |
| echo "TOTAL:".$total; |
atau kamu bisa pake query select sum seperti:
| <?php |
| $sql = "select sum(NxB) from nama_table"; |
| $q = mysql_query($sql); |
| $row = mysql_fetch_row($q); |
| echo "TOTAL:".$row[0]; |