Hello everyone,
First I'm new here so nice to meet you all,
I had try to insert data using codeigniter like this :
my views :
Code:
<?php echo form_open('index.php/testadddiscount');?>
$n = 1;
foreach($disc as $exist) {
echo "
<input name=\"iddisc".$n."\" type=\"text\" value=\"".$iddisc."\" class=\"textbox\" />
<input name=\"dname".$n."\" value=\"".$discount_name."\" type=\"text\" />
";
$n++
} // end foreach
<input type="submit" value="send" />
<?php echo form_close();?>
my models :
Code:
function discount() {
$query = $this->db->get('discount');
$query = $query->result();
$n =1;
foreach($query as $rows) {
$data[$n] = array(
'iddiscount'=> $_POST['iddisc'.$n],
'discountname' => $_POST['dname'.$n],
'status' => 1
);
$this->db->insert('test',$data[$n]);
$n++;
}
return $this->db->insert_id();
}
my controller :
Code:
function testadddiscount() {
$this->test_model->discount();
}
I had try code on above this will show value but unable to insert them into database.
please help me
Thanks