<?php $query = $DB_site->query('SELECT `user`, `amount`, SUM(`amount`) AS `total` FROM `donation` ORDER BY `amount` DESC LIMIT 10'); print('<table>'); print('<tr><th>User</th><th>Donation</th></tr>'); while ($row = $DB_site->fetch_array($query)) { print('<tr><td>' . $row['user'] . '</td><td>' . $row['amount'] . '</td></tr>'); } print('<tr><th colspan="2">Total: ' . $row['total'] . '</th></tr>'); print('</table>'); ?>