0
votes
for ($i = 0; $i < $count; $i++) {
  $this->data["schedule_count"] = $count;
  $this->data["user_travels" . $i] = $this->travel_order_model->get_travel_schedule($this->data["user_dates"]{$i}->id);
}

Error:

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: user_travels

Filename: travel_order/travel_order_report_summary.php

Line Number: 212

A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: travel_order/travel_order_report_summary.php

Line Number: 213

2
If you are using the data in view then you don't need any $this->data[]. You just have to mention the variable name. - kishor10d

2 Answers

1
votes
for ($i = 0; $i < $count; $i++) {
  $this->data["schedule_count"] = $count;
  $this->data["user_travels"][$i] = $this->travel_order_model->get_travel_schedule($this->data["user_dates"][$i]->id);
}
$this->load->view('your_view_file', $data);

Your View File, You can print data this way,

foreach($user_travels as $travelData){
    print_r($travelData);
}
1
votes
for ($i = 0; $i < $count; $i++) {
  $this->data["schedule_count"] = $count;
  // pass Id 
  $this->data["user_travels"][$i] = $this->travel_order_model->get_travel_schedule($this->data["user_dates"][$i]->getId());
}