我需要使用 join 将数据库值获取到我的文本框中

i need to get dabase values in to my textbox using join

我的观点

<?php foreach ($single as $admin): ?>

                    <table class="table">
                    <tbody>                   

                        <div class="form-group margin_bot_20 " >
                        <div class="col-sm-2">Name of Company</div>
                        <div class="col-sm-10"> 
                            <input type="text" placeholder="Name of Company"     class="form-control txtbx-height" id="compneyname" value="<?php echo $admin->user_id; ?>" name="compneyname"  data-parsley-trigger="change"  data-parsley-required-message="Builder Name is required." s>                           

                        </div>

                      <?php endforeach; ?>

我的模型

public function update_admin($data){
            $this->db->select('*');
            $this->db->from('tbl_user');
            $this->db->where('user_id', $data);
            $query = $this->db->get();
            $result = $query->result();
            return $result;
           }   

我的控制器

$this->user->update_admin($user_id);
            $data['single'] = $this->user->update_admin($user_id);
            $this->load->view('edit_user', $data);
            $this->input->post('user_id');
            $this->layout->view_render("admin/user/edit_user", $data);

            $data = array(
            'companyname' => $this->input->post('compnayname'),
            'name' => $this->input->post('name'),
            );

我需要从两个不同的表中获取值,例如 tbl_user 和 tbl_userinfo 并将它们显示到文本框显示我可以编辑它。

试试这个:

$this->db->select('*');
                $this->db->from('tbl_user');
                $this->db->join('tbl_userinfo', 'tbl_user.user_id = tbl_userinfo.user_id');
                $this->db->where('tbl_user.user_id', $data);
                $query = $this->db->get();
                $result = $query->result();
                return $result;