I am trying to select the details of the users from a table in mysql database but it is not working. This is the code in my model :-
public function getuserdetails()
{
$user_email = $this->input->post('email');
$query_userdetails = $this->db->query("SELECT *
FROM users WHERE email = '$user_email' ");
return $query_userdetails->result_array();
}
This is not working. But if I put the actual email id in the query instead of $user_email it works but not properly i.e if I use :-
$query_userdetails = $this->db->query("SELECT * FROM users WHERE
email = '[email protected]' ");
In this case it returns a result. My controller code to accept the result is :-
$data['details'] = $this->model_userdetails->getuserdetails();
But the problem is that when I access $details in view :-
echo $details['name']."<br />";
it does not recognize 'name'. name is the field in the database where the name of the users are stored. But if I try to retrieve it in a foreach loop it is working :-
foreach($details as $udetails)
{
echo $udetails['name']."<br />";
}
GET
method. Check it. – Yogesh Suthar Feb 23 at 6:13