MY UPDATED QUESTION IS HERE:
Fetching information from the database MYSQL & Codeigniter
please see :)
I just want to ask what's the problem with this code. I've been trying to figure this out since last night. And I again, i'm posting this question. There's something wrong with my syntax I guess.
function member_here()
{
$this->db->select('');
$this->db->from('membership');
$this->db->where('username',$this->input->post('username'));
$q=$this->db->get('');
if($q->num_rows() > 0) {
$data = array();
foreach($q->result() as $row) {
$data=$row;
}
return $data;
}
}
So anyway. The output for that would be selected information from the database.
but
I figured that some parts of the code is correct because it is giving an output. But its still not right.
lets say i have this data:
|-------Name-----|-----Username-----|---------Email Address----------|
| Marishka | marishkapv | marishka@email.com |
| John | johndoe | john@doe.com |
| Dennis | dennisv | dennis@v.com |
So, I logged in using Marishka. After the successful log in. The information I see in my home page is the information of dennis
Same with if I log in john
The data being fetched from the database is the last data stored. How can I select from the database which belongs to the specific username i logged in
Please answer. Thank you so much!
HERE'S AN UPDATE
this is the code in my view form
<?php
$CI =& get_instance();
$CI->load->model('membership_model');
$result = $CI->membership_model->member_here();
?>
User Information:
</br></br></br>
Name: <?php echo $result->first_name; echo " "; echo $result->last_name;?><br/></br>
Email Address: <?php echo $result->email_address; ?><br/></br>
Date of Birth: <br/></br>
Gender: <?php echo $result->gender; ?><br/></br>
</br></br></br>
Account Information:<br/></br></br>
Username:<?php echo $this->session->userdata('username'); ?><br/></br>
Security Question: <?php echo $result->security_question; ?> <br/></br>
Security Answer: <?php echo $result->security_answer; ?> <br/></br>