Welcome Guest, Not a member yet? Register   Sign In
Please HELP!! Having problem in displaying an array made by the controller at the view part...
#1

[eluser]brianbabu[/eluser]
Please analyze the following code
Code:
$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


Messages In This Thread
Please HELP!! Having problem in displaying an array made by the controller at the view part... - by El Forum - 12-29-2012, 12:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB