Welcome Guest, Not a member yet? Register   Sign In
Insert associative array to database array to string problem
#1

[eluser]Ignis Avis[/eluser]
In the form input doing it like following

Code:
<?php foreach($fee_cat as $row) { ?>
<label>&lt;?php echo $row['fc_name']; ?&gt;</label>
<span class="field">&lt;input type="checkbox" name="fc_id[]" value="&lt;?php echo $row['fc_id']; ?&gt;" /&lt;/span>
&lt;?php } ?&gt;

In the model

Code:
public function add_new_grade() {

        $gt_name = $this->input->post('gt_name');
        $gt_fee = $this->input->post('gt_fee');
        $fc_id = $this->input->post('fc_id');
        $data_to_store = array(
            'gt_name' => $gt_name,
            'gt_fee' => $gt_fee,
        );
        $this->db->insert('grade_table', $data_to_store);
        $id = $this->db->insert_id();
        $this->tableTag($fc_id,$id);
    }

    function tableTag($theData, $itemID) {
        foreach ($theData as $d) {
            $data_to_store = array(
                'gf_fc_id' => $d,
                'gf_gt_id' => $itemID
            );
            $this->db->insert('grade_fee', $data_to_store);
        }
    }

Its causing an array to string convertion error. What I am doing wrong? Thanks in advance.
#2

[eluser]PravinS[/eluser]
Code:
$fc_id = $this->input->post('fc_id');
above code will return checkbox values in array format


check $fc_id values using this code, you will understand, what I am saying
Code:
print_r($fc_id);
#3

[eluser]PravinS[/eluser]
Code:
$fc_id = $this->input->post('fc_id');
above code will return checkbox values in array format,

check using
Code:
print_r($fc_id);




Theme © iAndrew 2016 - Forum software by © MyBB