<?php

/*error_reporting(0);*/
$koneksi = mysqli_connect("localhost","akutans1","kh","pt_gadai") or die (mysqli_connect_error());
// untuk data yg gagal disimpan
/*echo "<pre/>"; print_r($_POST);*/

if(isset($_POST['Proses']) AND isset($_POST['no'])){
}
$delete = "DELETE FROM kolek ";
if(mysqli_query($koneksi, $delete)){
 /* echo "Records were deleted successfully.";*/
} else{
    echo "ERROR: execute $delete. " . mysqli_error($koneksi);
}

$no =  $_POST['rekening'];
$jum = count($no);
$rekening     = $_POST['rekening'];
$tgl          = $_POST['tgl'];
$kol          = $_POST['kol'];

for($i=0; $i <$jum; $i++){
//tidak boleh terlalu banyak 
  // untuk update sukses 100%
/*$query = mysqli_query($koneksi,"UPDATE pinjaman SET kol='$kol[$i]' WHERE rekening='$no[$i]' ")or die(mysqli_error($koneksi));*/
// untuk tambahdata sukses 100%
$query = mysqli_query($koneksi,"INSERT INTO kolek SET tgl='$tgl', rekening='$rekening[$i]',kol='$kol[$i]' ")or die(mysqli_error($koneksi));
}
echo "<script type='text/javascript'>alert('Data Sudah diproses, silahkan lakukan cari data');
window.location = '../home.php?home=d1335ae7d5e6736c8ceda87fbded4aa1';
</script>";
/*echo "Data Sukses Disimpan sebanyak".$jum. " Data";*/

?>
