Welcome Guest, Not a member yet? Register   Sign In
Save List Box Values in Many Tables
#1

[eluser]shahmy[/eluser]
Hi, I have 2 list boxes in my view. I am moving selected list box values from left to right,
I want to know, "how to save the right list box values in table ?". If any one know, Please help me.
Thank You.
#2

[eluser]Derdiusz[/eluser]
Name your list box "as array" like:
Code:
<select name="right_side[]" multiple>
...
</select>
after posting your form (ie. with method="POST") you have $_POST['right_side'] which is an array with values from select. You can do:

Code:
foreach($_POST['right_side'] as $v)
{
$this->db->insert('your_table', array('right_value'=>$v));
}


Of course this is a sample code. right_value from insert query is a field in your database table.

Greetings
D.
#3

[eluser]shahmy[/eluser]
Hi Derdiusz, I was try what u post above. But the values not inserted in tables, i will copy my codes bellow, that is when i post the form the null values return to the model.
If u know please help me.

"My view"

Code:
&lt;?php echo form_open_multipart('teachers/videomatrials/insertmatrials',$frmname);?&gt;
<select multiple name="destination_stu[]"  size="4">
  </select>
&lt;input type="submit" value="Add"/&gt;
&lt;?php echo form_close();?&gt;

"My Model"

Code:
foreach($_POST['destination_stu'] as $stu_id)
                {
                    $this->db->insert('stu_to_sub', array('stu_id'=>$stu_id,
                    'sub_id'=>$sub_id,
                    ));
                
                                
                
                    $this->db->insert('stu_to_mod',array(
                    'stu_id'=>$stu_id,
                    'mod_id'=>$mod_id,
                    ));
                
                                
                
                    $this->db->insert('tech_to_stu',array(
                    'stu_id'=>$stu_id,
                    'tech_id'=>$this->session->userdata('tech_id'),
                    ));
                
                }

Thank You.




Theme © iAndrew 2016 - Forum software by © MyBB