그래서 내가 가입하고 싶은 테이블이 3 개 있습니다.Codeigniter : 3 개의 테이블을 결합하여보기에 데이터 표시
나는 응용 프로그램 내가 CodeIgniter의 구축, 그리고 난 3 개 테이블
클라이언트가 있습니다
-id
-phone_number을
-hospital_id
-smc_status
-testing_center_id
병원
-id내가 가지고있는보기에서
public function get_clients()
{
if($slug === FALSE)
{
$this->db->select('clients.*');
$this->db->from('clients');
$this->db->join('hospital', 'clients.id = hospital.id');
$this->db->join('testing_center', 'clients.id = testing_center.id');
$query = $this->db->get();
return $query->result_array();
}
$query = $this->db->get_where('clients');
return $query->row_array();
}
: -name
Testing_center 모델에서
-id
-name
,이이
<tbody>
<?php foreach ($clients as $client_item): ?>
<tr>
<td><?php echo $client_item['phone_number'] ?></td>
<td><?php echo $client_item['smc_status'] ?></td>
<td><?php echo $client_item['hospital_id'] ?></td> //i wish to have the hospital name here
<td><?php echo $client_item['testing_center_id'] ?></td> //i wish to have the testing center name here
<td><?php echo $client_item['language'] ?></td>
<td><a href="#">View</a></td>
</tr>
<?php endforeach ?>
</tbody>
그러나 그것은 becau입니다. 세 번째와 네 번째 td에 병원 이름과 검사 센터 이름을 표시하지 않았습니다. 어떻게해야할까요? 어떤 이유로 작동하지 않는 몇 가지 기법을 시도했습니다. 이 대신
$this->db->join('hospital', 'hospital.id = clients.id');
$this->db->join('testing_center', 'testing_center.id = clients.id');
: 그들은 같은 경우
$this->db->join('hospital', 'clients.id = hospital.id');
$this->db->join('testing_center', 'clients.id = testing_center.id');
을 또한
클라이언트 * 의 * 클라이언트 확인
당신이하려고하면 어떻게됩니까
처럼 sholud하지만 난 HTTP 오류 500 이유는 무엇입니까를 받고 결국? – raybesiga
선택했는데 일부 맞춤법 오류가 발생했습니다. 조언 해주셔서 감사합니다! – raybesiga
양식을 채우고 데이터를 다시 다른 테이블로 푸시하려고합니다. 나는 어떻게 그것에 대해 갈 것인가? 먼저 데이터베이스에 양식을 바인딩하여 조인을 이해하거나 데이터베이스에서 예상되는 것과 비슷한 입력 텍스트를 배치해야합니까? – raybesiga