[eluser]redraw[/eluser]
Hello All,
I have problem with multiple update
here my view :
Code:
<form name="form1" id="form1" method="post" action="">
<?php $i = 0; ?>
<?php foreach($detail->result() as $rows):?>
<input type="hidden" name="<?php echo 'trans['.$i.'][master_id]'; ?>" value="<?php echo $rows->master_id; ?>">
<input type="hidden" name="<?php echo 'trans['.$i.'][user]'; ?>" value="<?php echo $rows->user; ?>">
<input type="hidden" name="<?php echo 'trans['.$i.'][no_bukti]'; ?>" value="<?php echo $rows->no_bukti; ?>">
<input type="hidden" name='<?php echo 'trans['.$i.'][jenis]'; ?>' id='jenis' value="<?php echo $rows->jenis; ?>" class='trans[][jenis]'>
<select name="<?php echo 'trans['.$i.'][code]'; ?>" id="<?php echo 'trans['.$i.'][code]'; ?>"style='width:35%'>
<?php
echo "<option value=".$rows->code.">" . $rows->code ." - ". $rows->account . "</option>";
foreach($detail_nomer->result() as $row){
echo "<option value=".$row->code.">" . $row->code ." - ". $row->account . "</option>";
}
?>
</select>
<input type="text" name="<?php echo 'trans['.$i.'][keterangan]'; ?>" id="<?php echo 'trans['.$i.'][keterangan]'; ?>" value="<?php echo $rows->keterangan;?>" style='width:45%'>
<input type="text" name="<?php echo 'trans['.$i.'][nilai]'; ?>" id="<?php echo 'trans['.$i.'][nilai]'; ?>" value="<?php echo $rows->nilai;?>" class='trans[][nilai]'>
<br>
<?php $i++; ?>
<?php endforeach;?>
here is my controller :
Code:
function gl_edit_trans()
{
$y = 1;
while($y <= count($_POST['trans']))
{
if (array_key_exists($y, $_POST['trans']))
{
$master_id = $_POST['trans'][$y]['master_id'];
$no_bukti = $_POST['trans'][$y]['no_bukti'];
$code = $_POST['trans'][$y]['code'];
$keterangan = $_POST['trans'][$y]['keterangan'];
$keterangan = strtoupper($keterangan);
$user = $_POST['trans'][$y]['user'];
$nilai = $_POST['trans'][$y]['nilai'];
$nilai = str_replace(',','',$nilai);
print_r($_POST['trans']);
$data = array(
'master_id' => $master_id,
'no_bukti' => $no_bukti,
'code' => $code,
'keterangan' => $keterangan,
'user' => $user,
'nilai' => $nilai
);
$this->gl_model->edit_master_trans($data);
}
$y++;
}
$this->gl_lihat_trans();
}
and this is my model :
Code:
function edit_master_trans($newdata = array())
{
if( ! empty($newdata));
//the problem is -- > $this->db->where('master_id',$newdata);
//the problem is -- > $this->db->where('no_bukti',$newdata);
$this->db->update('gl_master',$newdata);
}
the problem is in my model. i no idea to parsing array post of the 'master_id' and 'no_bukti' into the model.
thankyou