我一直试图这样做,但似乎不会去任何地方。
问题是,数据在视图中没有显示为组合框,它显示此错误;
遇到PHP错误严重性:通知消息:未定义属性:stdClass :: $ Campus文件名:views / energy_search_campus.php行号:28“> c_name。
所以dunno问题应该在...模型,视图,控制器甚至数据库中。提前谢谢。
型号:
function campus_finder()
{
$this->db->group_by('campus');
$this->db->order_by('faculty', 'asc');
$query = $this->db->get('cpanel_energy');
if($query->num_rows()>0) {
foreach($query->result() as $row) {
$services[$row->id] = $row;
}
return $services;
}
}
查看:
<div class="finder">
<div>
<label>Campus</label>
</div>
<select
id="campus"
name="campus"
class="form-control"
>
<option value="">----</option>
<?php foreach($catalogue as $item): ?>
<option value="<?php echo $item->Campus; ?>"
<?php if($campus) echo ($item->campus==$campus)? 'selected' : ''; ?>
><?php echo $item->campus; ?></option>
<?php endforeach; ?>
</select>
</div>
控制器:
function campus_search()
{
$submit = $this->input->post('send');
$campus = $this->input->post('campus');
$year = $this->input->post('year');
if($submit=='goback')
{
redirect("energy/catalogue/");
}
else
{
$data['catalogue'] = $this->model_energy_consumption->campus_finder();
$data['voucher'] = $this->model_energy_consumption->results_campus();
$data['services'] = $this->modelo_energy_consumption->services_catalogue_campus();
$data['campus'] = $campus;
$data['year'] = $year;
DB:
MAINTENANCE_JOB_ITEMS
|----|---------|---------|--------|
| id | account | faculty | campus |
|----|---------|---------|--------|
1 898946 f_name c_name
答案 0 :(得分:0)
在模型中,您返回$ services,但值保存在$ servicios变量
中答案 1 :(得分:0)
first call select function to select some record then group them
like this :
$this->db->select('user_id, first_name,last_name');