How to insert or update array to php mysql
Publish Date : 26-05-2019 , dibaca 5429 kali, Hari ini dibaca : 1 kali ,0 comments
$data = array();
$ids = $_POST['id'];
$input = $_POST['input'];
$edit = $_POST['edit'];
$hapus = $_POST['hapus'];
$cetak = $_POST['cetak'];
if($ids ){
foreach ($ids as $key => $value){
$info_user = array(
'user_id' => $value,
'input' => !empty($input[$value]) ? 1: 0,
'edit' => !empty($edit[$value]) ? 1: 0,
'hapus' => !empty($hapus[$value]) ? 1: 0,
'cetak' => !empty($cetak[$value]) ? 1: 0,
);
$data[] = $info_user;
}
}
foreach ($data as $test) {
mysqli_query($konek, "UPDATE setting SET input = '$test[input]',edit = '$test[edit]', hapus = '$test[hapus]' , cetak = '$test[cetak]' WHERE id_set = '$test[user_id]'");
}