Welcome Guest, Not a member yet? Register   Sign In
unable to fetch records from database
#1

Hi
whats wrong in my following query. i got the error
Error Number: 1054
Unknown column 't.user_id' in 'where clause'
-------------------------my query------------

function ShowTransData($data){
$this->db->select('*')
->from('transaction')
->join('user', 'transaction.user_id = user.user_id')
->where('t.user_id='. $data);
$query = $this->db->get();
return $query->result();
Reply
#2

(This post was last modified: 01-06-2016, 02:27 AM by mr_pablo.)

(01-06-2016, 02:16 AM)nady Wrote: Hi
whats wrong in my following query. i got the error
Error Number: 1054
Unknown column 't.user_id' in 'where clause'
-------------------------my query------------

function ShowTransData($data){
$this->db->select('*')
->from('transaction')
->join('user', 'transaction.user_id = user.user_id')
->where('t.user_id='. $data);
$query = $this->db->get();
return $query->result();

You are trying to get `t.user_id` but you have not assigned `t` to the `transaction` column

PHP Code:
function show_trans_data($data){
    
$this->db->select('*')
    ->
from('transaction as t')
    ->
join('user''t.user_id = user.user_id')
    ->
where('t.user_id'$data); // I'm guessing this is just an ID number?

    
$query $this->db->get();

    return 
$query->result();


I also tidied up your function.
Reply
#3

Try the following code:


PHP Code:
function show_trans_data($data){
 
   $this->db->select('*')
 
   ->from('transaction as t')
 
   ->join('user''t.user_id = user.user_id')
 
   ->where('t.user_id = "' $t.user_id '"');

 
   $query $this->db->get();

 
   return $query->result();

Reply




Theme © iAndrew 2016 - Forum software by © MyBB