[eluser]Bigil Michael[/eluser]
now i modified controller and model.
now all errors are corrected
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;
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
.
.
.
2110000000
if i remove this code
Code:
<?php foreach($crow['list'] as $krow) {
echo $krow;
}
?>
and use only
Code:
(<?php echo $crow['list']?>)//[after making changes in controller]
then for each sub-subcategory it will print the same count
so. iam totally failed to solve this problem.
can anyone help me???