• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Access this variable within the view

#1
I have the following two functions of which I load them into my "welcome_message" view passing through the parameters the $page_data. I am trying to access $result['unknown_Leads_not_assigned_previous_day']=$query->result_array(); in the view but I am getting errors. Am I returning something wrong? I am trying to access with <?= $unknown['unknown_Leads_not_assigned_previous_day'] ?>. Can someone help please? Thanks!

PHP Code:
public function index() {
    
$this->load->database();

    
$page_data=array();

    if (isset(
$_POST['date_end'])) {
        
$page_data['google']=$this->loadChannelData('google');
    }

    
$this->load->view('welcome_message'$page_data);
}

public function 
loadChannelData($channelKey) {
    else if(
$channelKey 'unknown') {
        
$page_data['unknown'] = $this->unknown($_POST['date_start'], $_POST['date_end']);
    }
}

public function 
unknown($start_date$end_date) {
    
$query=$this->db->query("SELECT COALESCE(sum(`lead_attorney`.`cost`), 0) as sale
    FROM `lead_attorney`
    JOIN `leads` ON `lead_attorney`.`lead_id` = `leads`.`lead_id`
    LEFT JOIN leads_segmentation ls ON ls.lead_id = `leads`.`lead_id`
    WHERE (
    `leads`.`test_mode` = FALSE
    AND ls.is_test_lead = FALSE
    AND `lead_attorney`.`status` NOT IN (8, 9)
    AND (DATE(lead_attorney.created_at) BETWEEN '
$start_date' AND '$end_date')
    AND `leads`.`source` = 3
    )"
);
    
$result['unknown_assigned_previous_day']=$query->result_array();

    
$query=$this->db->query("SELECT count(`lead_attorney`.`lead_id`)
    FROM `lead_attorney`
    JOIN `leads` ON `lead_attorney`.`lead_id` = `leads`.`lead_id`
    LEFT JOIN leads_segmentation ls ON ls.lead_id = `leads`.`lead_id`
    WHERE (
    `leads`.`test_mode` = FALSE
    AND ls.is_test_lead = FALSE
    AND `leads`.`lead_cost` != 0
    AND (DATE(lead_attorney.created_at) BETWEEN '
$start_date' AND '$end_date')
    AND `leads`.`source` = 3
    )"
);
    
$result['unknown_Leads_assigned_yesterday']=$query->result_array();

    
$query=$this->db->query("SELECT count(*) AS `count`
    FROM `leads`
    LEFT JOIN leads_segmentation ls ON ls.lead_id = `leads`.`lead_id`
    WHERE (
    `leads`.`lead_cost` = 0
    AND (DATE(leads.created_at) BETWEEN '
$start_date' AND '$end_date')
    AND `leads`.`test_mode` = FALSE
    AND ls.is_test_lead = FALSE
    AND `leads`.`lead_status` = 10
    AND `leads`.`duplicate` = 0
    AND `leads`.`source` = 3
    )"
);
    
$result['unknown_Leads_not_assigned_previous_day']=$query->result_array();
    return 
$result;

Reply

#2
loadChannelData() aren't returning anything. If it are doing so later on in the code. You need to make sure you have correct data in your $page_data array before passing it into the view.

And if it does, you need to do a var_dump() on $unknown in the view.

You are also subject of SQL Injections, I can drop or dump all your information if I wanted.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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