CodeIgniter Forums
problem in view page - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: problem in view page (/showthread.php?tid=41507)



problem in view page - El Forum - 05-10-2011

[eluser]Bigil Michael[/eluser]
controller
Code:
$build_array = array();
       $sub_result = array();
        $fleets = $this->Classifieds_model->select_all_classifieds();
        foreach($fleets as $row){
            $sub = $this->Classifieds_model->list_all_classifieds($row['id']);
            foreach($sub as $subsub)
            {
                $sub_result[] = $this->Classifieds_model->count_classifieds($subsub['id']);
            }
            $build_array[] = array (
                'fleets_array' => $row,
                'listefleets_array' => $sub,
                'list' => $sub_result
            );
        }
        $meow = $build_array;
        $this->data['meow'] = $meow;  
[code]
model
[code]
function count_classifieds($parent=0)
    {
        $count=0;
        $result_total    =    $this->db->query("SELECT COUNT(id) AS total  FROM classifieds WHERE categoryid='$parent' AND status=1");
        if($result_total->num_rows()>0){
            $row    = $result_total->row();
            $count    =    $row->total;
        }
        return $count;
    }
view
Code:
<?php foreach($meow as $crow){?>
    <?php echo $crow['fleets_array']['heading'];?>
        <?php
        foreach ($crow['listefleets_array'] as $lrow){?>
            <?php echo $lrow['heading'];?>
                    <?php foreach($crow['list'] as $krow) {
                        echo $krow;
                        }
                    ?>
        <?php  } ?>
<?php } ?>
in the result page it prints like this
2
21
.
.
.
211000033..

i want to print the count only
can anyone solve this problem???

in the controller iam getting the correct result, but i totally failed to send it to the view............


problem in view page - El Forum - 05-10-2011

[eluser]Nick_MyShuitings[/eluser]
At least link to your previous thread so people can read the backstory on everything that you've tried...

and post a var_dump of $meow, so that the people can see the final generated array... cuz you're just having a problem now figuring out how to play with your array (standard array functions).

Also... get rid of those php open and close tags on each line in your form... enclose the whole section and be done with it, or use foreach template tages <?foreach($a as $b):?> etc