Welcome Guest, Not a member yet? Register   Sign In
Loop inside a loop in controller.. help needed....:(
#3

[eluser]Roy MJ[/eluser]
Ive tried out join function and an error is logging in.. The model is as follows:

Code:
function get_total($id)
    {
        $count=0;
        $getid = $id;
        $this->db->select('COUNT(friends.id) AS total');
        $this->db->distinct();
            $this->db->from('friends');
        $this->db->join('members','friends.member_id ='. $getid);
        $result_total = $this->db->get();
        if($result_total->num_rows()>0){
            $row    = $result_total->row();
            $count    =    $row->total;
        }
        return $count;
    }

The error is :

Code:
A Database Error Occurred

Error Number: 1054

Unknown column '13' in 'on clause'

SELECT DISTINCT COUNT(friends.id) AS total FROM (`friends`) JOIN `members` ON `friends`.`member_id` =`13`

I cant figure out why the error. 13 is actually the id thats getting passed.. Anyone..??


Messages In This Thread
Loop inside a loop in controller.. help needed....:( - by El Forum - 04-03-2011, 11:21 PM
Loop inside a loop in controller.. help needed....:( - by El Forum - 04-03-2011, 11:28 PM
Loop inside a loop in controller.. help needed....:( - by El Forum - 04-04-2011, 12:19 AM
Loop inside a loop in controller.. help needed....:( - by El Forum - 04-04-2011, 01:07 AM
Loop inside a loop in controller.. help needed....:( - by El Forum - 04-04-2011, 11:59 PM
Loop inside a loop in controller.. help needed....:( - by El Forum - 04-05-2011, 12:12 AM
Loop inside a loop in controller.. help needed....:( - by El Forum - 04-05-2011, 12:22 AM
Loop inside a loop in controller.. help needed....:( - by El Forum - 04-05-2011, 12:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB