I'm trying to find the "users" current subscription on the database and display it's name in a view. Primary is the ID, so I'm using the User ID from session to find the appropriate row in the "subscriptions". This works as it should (I believe anyways). My problem is sending the selected data to the view. The only text that shows up in the view is "array".
What am I doing wrong?
Here's my code:
// displays current subscription in view
$userid = $this -> session -> userdata('user_id');
$this -> db -> select('subscription');
$this -> db -> where ('id', $userid);
$query = $this -> db -> get('subscriptions');
$data['packagename'] = $query -> result_array();
Here's what I'm echoing in my view:
<? echo $packagename; ?>
EDIT: I looked into the FOREACH function in the CI manual. I plugged this in and feel a bit closer. I don't want anything overly complex, code wise like some of you have posted, as I'm just learning. So now when the page is rendered, the following text is displayed: string(9) "mrpopular"
// displays current subscription in view
$userid = $this -> session -> userdata('user_id');
$this -> db -> select('subscription');
$this -> db -> where ('id', $userid);
$query = $this -> db -> get('subscriptions');
foreach ($query->result() as $row)
{
$data['packagename'] = $row->subscription;
}