Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // $array = array(
- // 'a' => array('id_mesin' => 'mesin1', 'berat' => '1'),
- // 'b' => array('id_mesin' => 'mesin2', 'berat' => '2'),
- // 'c' => array('id_mesin' => 'mesin3', 'berat' => '3'),
- // 'd' => array('id_mesin' => 'mesin4', 'berat' => '4'),
- // 'e' => array('id_mesin' => 'mesin5', 'berat' => '5'),
- // 'f' => array('id_mesin' => 'mesin6', 'berat' => '6'),
- // 'g' => array('id_mesin' => 'mesin7', 'berat' => '7'),
- // 'h' => array('id_mesin' => 'mesin8', 'berat' => '8'),
- // 'i' => array('id_mesin' => 'mesin9', 'berat' => '9'),
- // 'j' => array('id_mesin' => 'mesin10', 'berat' => '10'),
- // 'k' => array('id_mesin' => 'mesin11', 'berat' => '11'),
- // 'l' => array('id_mesin' => 'mesin12', 'berat' => '12')
- // );
- $koneksidb = mysql_connect("localhost","root","");
- $con = mysql_select_db("latihan",$koneksidb);
- if(!$con)
- {
- echo "Koneksi GAGAL ke Penjualan or Server Down Hub. Admin!";
- }
- echo $query = "SELECT tgl, id_mesin, brt_nyata, akm_mesin
- FROM harian
- WHERE tgl = '2015-04-01'
- ORDER BY id_mesin, tgl ASC";
- $hasil = mysql_query($query);
- $array = mysql_fetch_assoc($hasil);
- echo '<table border="1">';
- //set akm ke default yaitu nol
- $akm = 0;
- foreach ($array as $value) {
- echo '<tr>';
- echo '<td>';
- echo $value['id_mesin'];
- echo '</td>';
- echo '<td>';
- echo $value['berat'];
- echo '</td>';
- echo '<td>';
- // akm adalah akm sebelumnya ditambah berat
- $akm = $akm + $value['berat'];
- echo $akm;
- echo '</td>';
- echo '</tr>';
- }
- echo '</table>';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement