How can I pass variables in a foreach loop into a view?

#8
[eluser]alexandervj[/eluser]
hm that sounds a little over my head at the moment. I just started using CodeIgniter.

Maybe I'll just start with passing the value to another view and try doing it with a popup later on.

So in my view I have...

Code:
<?php echo anchor("main/request_details/$r->Submitted", 'View'); ?>


in my model i have the function...

Code:
function getDetail(){
        $q = $this->db->query("SELECT `submit_time` AS 'Submitted',
                max(if(`field_name`='firstName', `field_value`, null )) AS 'firstName',
                max(if(`field_name`='lastName', `field_value`, null )) AS 'lastName',
                max(if(`field_name`='email', `field_value`, null )) AS 'email',
                max(if(`field_name`='phone', `field_value`, null )) AS 'phone',
                max(if(`field_name`='affiliation', `field_value`, null )) AS 'affiliation',
                max(if(`field_name`='interest', `field_value`, null )) AS 'interest',
                max(if(`field_name`='productSheets', `field_value`, null )) AS 'productSheets',
                max(if(`field_name`='referredBy', `field_value`, null )) AS 'referredBy',
                max(if(`field_name`='comments', `field_value`, null )) AS 'comments',
                GROUP_CONCAT(if(`file` is null or length(`file`) = 0, null, `field_name`)) AS 'fields_with_file'
                FROM `wp_cf7dbplugin_submits`
                WHERE `form_name` = 'PSRequestForm' AND submit_time = ".$submitTime."
                GROUP BY `submit_time`
                ORDER BY `submit_time` DESC
                LIMIT 0,100");
        if($q->num_rows() > 0){
            foreach($q->result() as $rows){
                $data[] = $rows;
            }
            return $data;
        }
    }


and in my controller I have the function...

Code:
public function request_details(){
if ($this->session->userdata('is_logged_in')){
  $this->load->model('model_data');
  $data['rows'] = $this->model_data->getDetail($submitTime);
  $this->load->view('request_detail', $data);
  
} else {
     redirect('restricted');
}

    }

I feel like I'm almost there but a little confused still on how to get the data in the request_details.php view based on the submitTime value


Messages In This Thread
How can I pass variables in a foreach loop into a view? - by El Forum - 10-03-2014, 08:14 AM
How can I pass variables in a foreach loop into a view? - by El Forum - 10-03-2014, 03:19 PM
How can I pass variables in a foreach loop into a view? - by El Forum - 10-03-2014, 07:28 PM
How can I pass variables in a foreach loop into a view? - by El Forum - 10-03-2014, 08:17 PM
How can I pass variables in a foreach loop into a view? - by El Forum - 10-03-2014, 09:56 PM
How can I pass variables in a foreach loop into a view? - by El Forum - 10-06-2014, 08:16 AM
How can I pass variables in a foreach loop into a view? - by El Forum - 10-06-2014, 05:00 PM
How can I pass variables in a foreach loop into a view? - by El Forum - 10-14-2014, 03:31 PM
How can I pass variables in a foreach loop into a view? - by El Forum - 10-15-2014, 06:29 AM
How can I pass variables in a foreach loop into a view? - by El Forum - 10-16-2014, 09:31 AM
How can I pass variables in a foreach loop into a view? - by El Forum - 10-16-2014, 05:48 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.