Welcome Guest, Not a member yet? Register   Sign In
Copy data from one table and insert to another
#1

[eluser]red2034[/eluser]
Hello all! my first post excitement…

on a page in my views folder I have this code that is displaying all my classes available in ‘class_master’
Code:
<?php $classesMaster = $this->db->get('class_master')->result_array();
       foreach($classesMaster as $row):?>
                        
                        <tr><td width="50" align="center">    
              <a href="&lt;?php echo base_url();?&gt;index.php?student/classes/enroll/&lt;?php echo        $row['class_id'];?&gt;"  class="btn btn-gray btn-small">
                       &lt;?php echo get_phrase('enroll');?&gt;</a></td>

then on my controller php I have this function:
Code:
function classes($param1 = '', $param2 = '', $classesMaster = '')
    {    
    if ($param1 == 'enroll') {
  
       $class_info = $this->db->get_where('class_master' , array('class_id' => $param2));
      $data['class_id'] = $param2;
         $data['title'] = $class_info['title'];
                $this->db->insert('class', $data);
    redirect(base_url() . 'index.php?student/classes/', 'refresh');
     }

if I delete the $data[‘title’] = line it works fine by inserting the correct ‘class_id’ so I know everything is connected right, but as is after clicking the btn on the views page I am getting a blank white php page and the data has not been inserted into ‘class’

can anybody see the reason why??? again excited to find this forum!




Theme © iAndrew 2016 - Forum software by © MyBB