Welcome Guest, Not a member yet? Register   Sign In
Noob! Accessing a variable from an array
#4

[eluser]John_Betong[/eluser]
Try this:
Code:
// model
function get_resource()
{
  $query = $this->db->get('resources', 1);


  if ($query->num_rows() > 0)
  {
    $row = $query->row();
    
   // echo $row->name;
  }
    
  return $query->row();
}

// controller
function index()
{
  $this->load->model('data_model');
  $data['resources'] = $this->data_model->get_resource(); // get info from table

  // $data['no_props'] = $this->db->count_all('resources'); // count no. of rows in table

  $this->load->view('home_view', $data);
}

// view
<div>&lt;?php echo $resources->name;?&gt;</div>
&nbsp;
&nbsp;
edit: changed view $result-> to $resources->name
&nbsp;
&nbsp;
&nbsp;
&nbsp;


Messages In This Thread
Noob! Accessing a variable from an array - by El Forum - 04-10-2010, 05:13 AM
Noob! Accessing a variable from an array - by El Forum - 04-10-2010, 05:56 AM
Noob! Accessing a variable from an array - by El Forum - 04-10-2010, 06:01 AM
Noob! Accessing a variable from an array - by El Forum - 04-10-2010, 06:03 AM
Noob! Accessing a variable from an array - by El Forum - 04-10-2010, 06:04 AM
Noob! Accessing a variable from an array - by El Forum - 04-10-2010, 06:18 AM
Noob! Accessing a variable from an array - by El Forum - 04-10-2010, 06:23 AM
Noob! Accessing a variable from an array - by El Forum - 04-10-2010, 06:25 AM
Noob! Accessing a variable from an array - by El Forum - 04-10-2010, 06:28 AM
Noob! Accessing a variable from an array - by El Forum - 04-10-2010, 06:32 AM
Noob! Accessing a variable from an array - by El Forum - 04-10-2010, 06:38 AM
Noob! Accessing a variable from an array - by El Forum - 04-10-2010, 06:47 AM
Noob! Accessing a variable from an array - by El Forum - 04-10-2010, 07:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB