1
在下面的codeigniter代碼中,我已經放置了控制器,模型和視圖部分。我的目標是從考試表中刪除考試名稱。在我的情況下,它是從考試表中刪除考試名稱請幫我做這件事。 控制器使用codeigniter的下拉列表不會丟失任何數據
public function index()
{
//echo "inside form upload";
$data = array();
//$college_name = $this->session->userdata('college_name');
if($query = $this->import_model->get_exam_data())
{
$data['exam_data'] = $query;
}
//$this->load->view('student_view', $data);
$this->load->view('form_upload');
}
模型
function get_exam_data()
{
//$this->db->distinct();
$this->db->select("CONCAT(exam_name, ' ', month,' ',year) AS fullexamname", FALSE);//this will concat the value
//$this->db->where('college_name',$college_name);
$query = $this->db->get('exam_table');
return $query->result();
}
視圖
<?php
$data = array();
$data["Select Exam Name"] = "Select Exam Name";
foreach ($exam_data as $row)
{
$data[$row->fullexamname] = $row->fullexamname;
}
echo form_dropdown('exam_name', $data, 'small', 'class="dropdown_class" id="exam_name_id" ');
?>
*