これは私のコントローラーです:
<?PHP
class combobox extends CI_Controller
{
function dynamic_combobox()
{
$this->load->model('combobox_model');
$data['college'] = $this->combobox_model->getcollege();
$this->load->view('header', $data);
$this->load->view('left_menu', $data);
$this->load->view('manage_user', $data);
$this->load->view('footer', $data);
}
}
?>
これは私のモデルです:
$this->db->get('colleges');
$data = array();
if ($query->num_rows() > 0) {
foreach ($query->result_array() as $row){ $data[] = $row; }
}
$query->free_result();
return $data;
これは私の見解です:
<form action="<?php echo site_url(''); ?>" method="post">
College
<select name="id" id="id" style="width: 350px;">
<option class="droplist">Please select colleges</option>
<?
if (count($college)>0)
{
foreach ($college as $row)
{
echo "<option value='". $row['college_id'] . "'>" . $row['college_name'] . "</option>";
}
}
?>
</select>
Courses
<select>
<!--<option>UG</option>
<option>PG</option>-->
</select>
<input class="button" type="button" value="Refresh"/>
</form>