필자는 문자 그대로이 프로젝트의 나머지 부분을 지연시키기 위해 처음으로이 프로젝트를 시작했습니다.개체가 아닌 속성을 얻으려고합니까? PHP/Codeigniter
나는 데이터베이스 테이블에서 가져온 값을 사용하여 풀다운을 채우려고하므로 나중에 사용자가 풀다운에 더 많은 옵션을 추가하여 데이터베이스의 테이블에 추가 할 수 있도록하십시오.
MVC 디자인 패턴을 사용하는 Codeigniter 플랫폼 (PHP)을 사용하고 있습니다.
PHP는 오류가 심각 발생했습니다 : 여기
내가 무엇입니까 오류 메시지입니다 공지 메시지 :보기/submit.php 라인 번호 : 개체가 아닌 파일 이름의 속성을 얻으려고 노력 139
내 모델 기능은 여기에서 "직원"이라는 테이블에서 행을 검색합니다. 잘 작동합니다!
function retrieve_values()
{
$query = $this->db->get('staff');
if ($query->num_rows() > 0)
{
//true if there are rows in the table
return $query->result_array(); //returns an object of data
}
return false;
}
이 파라미터를 수신하고, 내보기로 전달 컨트롤러 기능이다. 잘 작동합니다! 나는 foreach 문을 사용하여 다음 옵션에 배열의 인스턴스를 울리는 오전 :
public function displayform()
{
//Checks if a user is logged in, if they are not they get redirected -
if ($this->session->userdata('name') == FALSE || $this->session->userdata('access_level') == FALSE)
{
redirect ('site/index');// to home page
}
//Stores the returned array in instance called "formdata" which will be passed to the view to be used in pulldown menu
$page['formdata']=$this->submit_model->retrieve_values();
//This loads the form
//Instance of "page" in array "page" specifies the file name of the page to load
$page['page'] = 'submit';
$this->load->view('template', $page);
return;
}
이는 문제의 원인이되는 뷰의 일부입니다. 대신의 배열, 배열의 배열을받을거야 즉, 당신은 result_array
을 사용했습니다
Array (
[0] => Array (
[staff_id] => 1
[name] => Cardiology Nurse
)
[1] => Array (
[staff_id] => 2
[name] => Radiology Nurse
)
[2] => Array (
[staff_id] => 3
[name] => Scrub Nurse
)
[3] => Array (
[staff_id] => 4
[name] => Circulating Nurse
)
[4] => Array (
[staff_id] => 5
[name] => Nurse
)
[5] => Array (
[staff_id] => 6
[name] => Training Nurse
)
[6] => Array (
[staff_id] => 7
[name] => Physiologist
)
[7] => Array (
[staff_id] => 8
[name] => Radiographer
)
[8] => Array (
[staff_id] => 9
[name] => Consultant
)
[9] => Array (
[staff_id] => 10
[name] => Radiologist
)
[10] => Array (
[staff_id] => 11
[name] => Cardiologist
)
[11] => Array (
[staff_id] => 12
[name] => Anaethestist
)
[12] => Array (
[staff_id] => 13
[name] => Non-medical Staff
)
)
사용하는 개체를 저장하는 세션과 함께 필요/포함? 세션에 객체를 저장하는 경우 세션을 시작하기 전에 객체의 클래스 정의가 포함 된 파일을 포함하거나 포함해야한다고 생각합니다. – James