我是codeigniter的新手,我的city
表结构就像
id,name,state_id
现在在视图中我得到了城市的所有数据,但我也想打印州名。但在city
表中我只有州名。所以我怎样才能在视图中获得州名
这是我的控制器。
public function city(){
$query = "SELECT * FROM ".CITYTABLE." ORDER BY name ASC";
$citydata = $this->masterModel->_get_data("",$query);
$this->create_template('manage-city', 'admin',compact('citydata'));
}
我的看法是
<tbody>
<?php
$i=1;
foreach ($citydata as $value) {
if($value->status == 1){
$status = "<span class='label label-success'>Active<span>";
}else{
$status = "<span class='label label-warning'>Deactive<span>";
}
?>
<tr>
<th scope="row"><?= $i++ ?></th>
<td><?= ucfirst($value->name) ?></td>
<td><?= $value->state_id ?></td>//HEREEEEEEEEEEE IS I WANT TO SHOW NAME OF STATE/*****/
<td><?= $status ?></td>
<td>
<?php echo anchor("master/edit_city/{$value->id}","<i class='fa fa-pencil'></i> Edit",['class'=>"btn btn-link"]) ?>
<span class="rmv-city" data-state="<?=$value->id?>"><i class="fa fa-trash"></i> Delete</span>
</td>
</tr>
<?php } ?>
</tbody>
这是我的架构