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