Welcome Guest, Not a member yet? Register   Sign In
get value from views and send it directly to model
#1

[eluser]rebornishard[/eluser]
I just wanted to get User.name on pageview.php
i tried to join table but it didn't work
if i change get_post to get $id i can call User.name
how to show User.name with get_post() not with get_post($id)
thank you Smile


Database
Code:
User has , id, name, email
Post has , id, user_id, title, content

Model modelpage.php
Code:
function get_posts()
{
  $this->db->select('*')
  ->from('post');
  $query=$this->db->get();
  return $query->result_array();
}

Controller page.php
Code:
public function posts()
{
  $data['postdata']=$this->modelpage->get_posts();
  $this->load->view('pageview.php',$data);
}

View pageview.php
Code:
<?php
  foreach($postdata as $pd)
{
  echo $pd['title'];
  echo '<br>'
  echo $pd['content'];
}
?&gt;


Messages In This Thread
get value from views and send it directly to model - by El Forum - 11-15-2012, 01:54 PM
get value from views and send it directly to model - by El Forum - 11-15-2012, 07:19 PM
get value from views and send it directly to model - by El Forum - 11-15-2012, 08:15 PM
get value from views and send it directly to model - by El Forum - 11-15-2012, 09:00 PM
get value from views and send it directly to model - by El Forum - 11-16-2012, 01:18 AM
get value from views and send it directly to model - by El Forum - 11-16-2012, 06:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB