• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to read a single record from result()?

#1
[eluser]Unknown[/eluser]
hello
i am trying to read a signle record from result().
in my blog system i need to show username which i will get only from userid field which is present in both tables (blog & users).
following is the code

code for controller
Code:
$blgs['p']=$this->eventdata->postevent($config['per_page'],$this->uri->segment(3));

code for model:-
Code:
$sql=$this->db->get('events',$num, $offset);
$this->db->limit(5);
if($sql->num_rows()>0)
{
foreach($sql->result() as $etdata)
{
         $brow=$sql->row();
         $idr=$brow->IdUser;
  $this->db->select('IdUser,UserName');
  $this->db->where('IdUser',$idr);
  $nsql=$this->db->get('users');
  $name=$nsql->row();
  $fuoname=$name->UserName;
  $this->session->set_userdata('funame',$fuoname);
  $eventdata[]=$etdata;
}
return $eventdata;
}

code for view:-
Code:
foreach($p as $row)
{
  echo $p->BlogTitle;
  echo posted by $this->session->userdata('funame');
}

Thanks for the help,


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.