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

#3
[eluser]Pascal Kriete[/eluser]
Taff has it spot on. Just to add my 2c though, returning the result_array from your model makes this a lot easier. Also, if you're using PHP5 you can do the loop very easily by using a reference in the foreach.
Code:
$comments = $this->Profile_data->getCoComments($clientID);

// No longer need the if, since we know it's an array.
foreach ($comments as &$comment)
{
    $comment['reply'] = $this->Profile_data->getReplies($comment->commentID);
}

$data['comments'] = $comments;

The same works in PHP4, but you have to do foreach($comments as $key => $comment) and then use $comments[$key]['reply'] similar to what Taff did.


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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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