[eluser]theknight[/eluser]
Model:
Code:
function dieAllegies($child_id) {
$this->db->select("Allergies.Id, CAST(Name AS TEXT) as Name, CAST(Symptoms AS TEXT) as Symptoms, CAST(Treatment AS TEXT) as Treatment, EffectiveTo, EffectiveFrom, Child_Id");
$q = $this->db->get_where('Allergies', 'Child_Id='.$child_id);
$details = $q->result_array();
print_r($details);
$details['Dietary'] = array();
$this->db->select("DietaryRequirements.Id, CAST(Requirement AS TEXT) as Requirement, CAST(Details AS TEXT) as Details, Child_Id");
$q = $this->db->get_where('DietaryRequirements', 'Child_Id='.$child_id);
$details['Dietary'] = $q->result_array();
print_r($details['Dietary']);
return array('details'=>$details);
}
Controller:
Code:
function dietAll(){
if($this->members->logged_in()){
$this->data['user']=$this->members->getDetails($this->session->userdata('user'));
$die_allergies=$this->childs_model->dieAllegies($this->uri->segment(3));
[b] $this->data['die_aller'] = $die_allergies['details'];[/b]
$this->data['child_details']=$child_details['details'];
$this->data['section']='child notices';
$this->load->view('dietaryall',$this->data);
}
}
View
Code:
<tr class="alt">
<td><?php echo $die_aller['Dietary']['Requirement']; ?></td>
<td><?php echo $die_aller['Dietary']['Details']; ?></td>
</tr>
I know the array has been set because it's outputted like this from the model:
Array ( [0] => Array ( [Id] => 3 [Requirement] => No butter[Details] => test [Child_Id] => 4 ) [1] => Array ( [Id] => 4 [Requirement] => No Sweets [Details] =>test [Child_Id] => 4 ) )
As you can see there are 2 rows. With them both nested within another array