Welcome Guest, Not a member yet? Register   Sign In
Display related data from user profile
#5

[eluser]doubleplusgood[/eluser]
Thanks man. I've just quickly put together this query;

Code:
public function getFeaturedVehiclesByUser(){
            $this->db->select('users.*, vehicles.*');
            $this->db->where('users.username', $username);
            $this->db->from('users');
            $this->db->join('vehicles', 'vehicles.userId = users.id', 'left');
            $this->db->where('vehicles', 'vehicles.featured = 1')
            $this->db->get();

            if ( $query->num_rows() == 1 )
            {
                return $query->row();
            }

            return FALSE;
        }

This should (in theory) find all vehicles where the userId of the profile being viewed matches and also where rows in the vehicles table are marked as featured. Hopefully this looks about right. Big Grin


Messages In This Thread
Display related data from user profile - by El Forum - 04-26-2010, 09:08 PM
Display related data from user profile - by El Forum - 04-27-2010, 02:00 AM
Display related data from user profile - by El Forum - 04-27-2010, 02:05 AM
Display related data from user profile - by El Forum - 04-27-2010, 02:11 AM
Display related data from user profile - by El Forum - 04-27-2010, 02:23 AM
Display related data from user profile - by El Forum - 04-27-2010, 02:35 AM
Display related data from user profile - by El Forum - 04-27-2010, 02:42 AM
Display related data from user profile - by El Forum - 04-27-2010, 02:46 AM
Display related data from user profile - by El Forum - 04-27-2010, 02:57 AM
Display related data from user profile - by El Forum - 04-27-2010, 03:06 AM
Display related data from user profile - by El Forum - 04-27-2010, 03:20 AM
Display related data from user profile - by El Forum - 04-27-2010, 11:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB