Welcome Guest, Not a member yet? Register   Sign In
Array parse problem
#2

[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.


Messages In This Thread
Array parse problem - by El Forum - 12-03-2007, 03:11 AM
Array parse problem - by El Forum - 12-03-2007, 03:29 AM
Array parse problem - by El Forum - 12-03-2007, 03:51 AM
Array parse problem - by El Forum - 12-03-2007, 04:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB