[eluser]tonanbarbarian[/eluser]
yes $data['count_images'] will always be the last value of $num->num_rows because the array is recreate in each pass through the loop
try doing this instead
Code:
if($gallery->num_rows != '0')
{
$data = array();
foreach($gallery->result() as $gal)
{
$num = $this->db->query("SELECT * FROM ci_images WHERE gall_id = $gal->id");
$data[] = array(
'galleries_list' => $gallery->result_array(),
'count_images' => $num->num_rows(),
);
}
$content .= $this->parser->parse('Gallerys.tpl', $data);
}
but personally I would try to use a single query to get all of the data and then build the array structure from that.
because for each "galleries" record you are running a seperate query - if one day you have 100 or even 1000 galleries you will be running 101 or 1001 queries when you can do it all in 1 query.