I'm building a application using codeigniter, this application has a profile page where all the information displayed is dependant on the user currently logged in. On the profile page I'm trying to set up a bio box so each user can write their own unique bio, this would be stored in the database. The code I've currently written is displaying a result on the page, but its not the correct result I was hoping for. The code I've written that relates to the problem is below.
In the model:
public function get_profile_information() {
$query = $this->db->query("SELECT profileText from users WHERE
idNumber = ?", $this->session->userdata('username'));
return $query->result_array();
}
In the controller:
public function loginprocess() {
$username = $this->input->post('idNumber');
$password = $this->input->post('passWd');
$query = $this->db->query("select * from users where idNumber='".$username."' and passWd='$password'");
$row = $query->num_rows();
if ($row) {
$this->session->set_userdata(array('username' => $username));
$sessionID = $this->session->userdata('username');
$data['title'] = 'Profile';
$data['profiletext'] = $this->news_model >get_profile_information();
$data['sessionID'] = $this->session->userdata('username');
$this->load->view('templates/header', $data);
$this->load->view('news/profile', $data);
$this->load->view('templates/footer');
} else {
$data['error'] = 'Invalid Login Details';
$data['title'] = 'Login';
$this->load->view('templates/header', $data);
$this->load->view('news/login', $data);
$this->load->view('templates/footer');
}
}
In the view:
<head>
<style type="text/css">
</style>
</head>
Welcome to the <?php echo $title; ?> page, <?php echo $sessionID; ?>
<?php var_dump($profiletext); ?>
<?php echo anchor('login/logout', 'logout'); ?>
On the webpage, the query to get the profile text from the database based on the logged in user gives this result
array(1) { [0]=> array(1) { ["profileText"]=> string(17) "Test Profile Text" } }
I was hoping just to get the "Test Profile Text" displayed. I've been unable to work out what is wrong, I'm fairly new to codeigniter and php so I don't have the knowledge to fix this issue.
var_dumpis for debugging. You have an array use it as such,echo $profiletext['profileText'];