[eluser]Unknown[/eluser]
ok, im just having a huge brain fart here... im trying to return a single row to my view, but im missing a step along the way. How do I pass a sinlge row of data from my db threw my controller and into my view page?
Model snip:
Code:
public function get_tech_name($id) {
$query = $this->db->get_where('techs', array('id' => $id));
$row = $query->row();
$name = $row->first_name . " " . $row->last_name;
return $name;
}
Controller snip:
Code:
public function index()
{
$name = $this->users_model->get_tech_name($this->session->userdata('techid'));
$data['tech_name'] = $name;
$data['query'] = $this->home_model->get_company_list();
$this->load->view('home_view', $data);
}
View: (The Welcome line is where I simply want to print the techs name, but it only prints the first letter of their name, because im doing it the wrong way lol)
Code:
<body>
<div id="container">
<h2>Welcome, <?php echo $query['fname'];// . " " . $lname; ?></h2> | Logout Link
</br>
</br>
<div id="body">
Company list:
</br>
<?php foreach($query as $item): ?>
link disabled ="<?php base_url();?>home/view/<?php echo $item['id']; ?>"><?php echo $item['company_name']; </br>
<?php endforeach; ?>
</div>
</div>
</body>
</html>