bradgrafelman;10985886 wrote:What "array called dietary" ? So far, the word "dietary" hasn't shown up at all in your print_r()-like output you've shown us. This brings me to my next question...
What code are you using to generate that output? In other words, assuming you are indeed using [man]print_r/man, what variable are you outputting? Is it the $die_aller variable that you're attempting to loop over above?
Also, either view the source of the page or wrap the print_r() output in <pre>..</pre> tags to preserve the whitespace - makes it a lot easier for us and you to read and understand the array structure that way.
I am using a MVC framework called codeigniter, everything is as follows:
Model
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
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:
<tr class="alt">
<td><?php echo $die_aller['Dietary']['Requirement']; ?></td>
<td><?php echo $die_aller['Dietary']['Details']; ?></td>
</tr>