Good day, i'm trying to save
to my table.
function save()
{
extract(populateform());
echo "<pre>";print_r(populateform());
$tipenya = $this->modelmodel->showdata("SELECT * From user_type");
foreach($tipenya as $types)
{
if($pilihan[$types->id_tipe] != ''){
foreach($pilihan[$types->id_tipe] as $values){
echo "insert into tbl a value ('".$values.','.$types->id_tipe."')<br>";
}
}
}
}
and here is data that i want to save
Array
(
[pilihan] => Array
(
[TP001] => Array
(
[0] => 2
)
[TP003] => Array
(
[0] => 2
)
)
)
the result from print_r($tipenya)
Array
(
[0] => stdClass Object
(
[id_tipe] => TP001
[deskripsi] => Developer
[flag] => 1
)
[1] => stdClass Object
(
[id_tipe] => TP002
[deskripsi] => Admin
[flag] => 1
)
[2] => stdClass Object
(
[id_tipe] => TP003
[deskripsi] => Outlet
[flag] => 1
)
)
and here is the error Message: Undefined index: TP002
. But when i try to input this
Array
(
[pilihan] => Array
(
[TP001] => Array
(
[0] => 1
)
[TP002] => Array
(
[0] => 1
)
[TP003] => Array
(
[0] => 1
)
)
)
there aren't any error. I'm trying use this but no help
if($pilihan[$types->id_tipe] != ''){ }