View Single Post
12-29-2012, 07:33 AM
#1
unikorndesigns is offline unikorndesigns
unikorndesigns's Avatar
Status: Junior Member
Join date: May 2011
Location:
Expertise: Web Designing and Development
Software: Photoshop, Dreamweaver and etc
 
Posts: 41
iTrader: 0 / 0%
 

unikorndesigns is on a distinguished road

  Old  CodeIgniter Framework help

Please analyze the following code. This is being used in CodeIgniter framework...

$results["rows"]=$this->Category_model->getAll();
$i=0;
while($i<count($results["rows"]))
{
//$parentids[]=$results["rows"][$i]->cat_id;
$disparray[]=array(
"cat_id" => $results["rows"][$i]->cat_id,
"cat_name" => $this->Category_model->fetchcatinfo($results["rows"][$i]->cat_id, "cat_name"),
"cat_parent_id" => $this->Category_model->fetchcatinfo($results["rows"][$i]->cat_id, "cat_parent_id"),
"cat_desc" => $this->Category_model->fetchcatinfo($results["rows"][$i]->cat_id, "cat_desc"),
"cat_num_posts" => $this->Category_model->fetchnumposts($results["rows"][$i]->cat_id),
"cat_parent_id_name"=>$this->Category_model->fetchcatinfo($this->Category_model->fetchcatinfo($results["rows"][$i]->cat_id, "cat_parent_id"), "cat_name")
);
$array=explode(",",$this->Category_model->fetchallkids($results["rows"][$i]->cat_id,0));
foreach($array as $item)
{
if(strlen($item)>0)
{
$spacecount=substr_count($item,"&nbsp;");
$id=str_replace("&nbsp;","",$item);
$spaces=array();
while($spacecount>=0)
{
$spaces[]="&nbsp;";
$spacecount--;
}
$disparray[]=array(
"cat_id" => $id,
"cat_name" => implode($spaces).$this->Category_model->fetchcatinfo($id, "cat_name"),
"cat_parent_id" => $this->Category_model->fetchcatinfo($id, "cat_parent_id"),
"cat_desc" => $this->Category_model->fetchcatinfo($id, "cat_desc"),
"cat_num_posts" => $this->Category_model->fetchnumposts($id),
"cat_parent_id_name"=>$this->Category_model->fetchcatinfo($this->Category_model->fetchcatinfo($id, "cat_parent_id"), "cat_name")
);
}
}
$i++;
}
// echo "Parent ID : ".$parentids[0]["cat_id"]."<br><br>";
// echo "The array being passed to the view part: <br>";
foreach($disparray as $item)
{
$finalarray["row"]=implode("|",$item);
}
$this->load->view("category", $finalarray);

In the view section when i try to output the array like print_r($row). It shows only the last element. When i try to display the contents of the $disparray in the controller part, its working fine.

I would like to know if instead of making and transferring $finalarray if i just transfer the $disparray how will i be able to display the contents of the array in the view part? Thanks in advance

Reply With Quote