• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
nesting mysql results, need help passing the array to my view

#1
[eluser]skattabrain[/eluser]
ok, still new to CI ... and object orientated design. i have no problems doing this procedurally.

creating a profile page for users ... on this page i load their details, then any comments made about them. i also want to include a list of replies for each on those comments.

i pass the data to my view like this ...

Code:
$this->load->view('profile.php', $data);

so i fetch my client, then all comments made on them, here's the code to fetch the comments ...

Code:
$comments = $this->Profile_data->getCoComments($clientID);
$data['comments'] = $comments;

now, i get the replies to each of these comments ...
Code:
if ($comments->num_rows() > 0)
{
foreach ($comments->result() as $comment)
$replies = $this->Profile_data->getReplies($comment->commentID);
}

the trouble i'm having is attaching this new reply array to the exisiting comment array ... so in my view i can simply loop through each comment, and while in a comment, i check for replies and loop through them before moving to my next comment. not really sure how to do this ... again, i've done this procedurally forever now ...


Messages In This Thread
nesting mysql results, need help passing the array to my view - by El Forum - 05-16-2008, 11:29 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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