내보기로 데이터를 전달하려고합니다. 모델 -> 컨트롤러 ->보기.mysql 데이터 codeigniter를 가져올 수 없습니다.
내 모델 :
class Records_model extends CI_Model {
public function get_records($array){
$query = $this->db->select('*')->from('records')->where('type', $array['type'])->get();
foreach ($query->result_array() as $row){
$data = array(
"id" => $row['id'],
"country" => $row['country'],
"event" => $row['event'],
"date" => $row['date'],
"selection" => $row['selection'],
"odds" => $row['odds'],
"result" => $row['result']
);
}
return $data;
}
}
내 컨트롤러 기능 :
public function basketball(){
$data = array(
"type" => 1
);
$this->load->model('records_model');
$data['records'] = $this->records_model->get_records($data);
$this->load->view('basketball', $data);
}
내보기 :
<?php foreach($records as $record){ ?>
<tr class="gradeA" id="id_65">
<td class="center"><?=$record['id'];?></td>
<td><?=$record['selection'];?></td>
</tr>
<?php } ?>
하고 난 단지 아무것도 의미 번호를받는 모든 (1,1 후
, 1,2,4, R, N) 그래서이 코드에 어떤 문제가 있습니까?
내 대답을 확인하십시오. 나는 그것을 더 명확하게했고 그것이 효과가있다! –