Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //--
- echo "<table>";
- $sql="SELECT id,masuk,pulang,pulang-masuk AS selisih FROM tabel";
- $result=$db->query($sql);
- $total=0; //-- inisialisasi nilai total
- while($row=$result->fetch_object()){
- echo "<tr><td>{$row->id}<td></td>{$row->masuk}<td></td>{$row->pulang}<td></td>{$row->selisih}</td></tr>";
- $total+=$row->selisih; //-- lakukan akumulatif penjumlahan dalam loop, simpan hasilnya dalan variabel $total
- }
- echo "<tr><td></td><td></td><td>total jam/bulan<td></td>{$total}</td></tr>"; //-- tampilkan nilai $total, setelah semua looping dilakukan
- ?>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement