在我看来,我在变量'slug'和'judul'中收到错误非法sting偏移量。你能告诉我什么是问题。
控制器
function index()
{
$slug = $this->uri->segment(2);
$this->data['halaman'] = $this->mhalaman->get_profil($slug);
if (empty($this->data['halaman'])) {
show_404();
}
$this->data['judul'] = $this->data['halaman']['judul'];
//var_dump($halaman_item['slug']);
$this->data['orang'] = $this->mlogin->dataPengguna($this->session->userdata('username'));
$this->data['contents'] = $this->load->view('page', $this->data, true);
$this->load->view('template/wrapper/mahasiswa/wrapper_content',$this->data);
}
视图
<div class="section ui dropdown link item">
<span class="count">Profil</span>
<div class="menu">
<?php foreach ($halaman as $dt) : ?>
<div class="item">
<a href="/tkd/index.php/page/<?php echo $dt['slug'] ?>"><?php echo $dt['judul'] ?></a> //line error
</div>
<?php endforeach; ?>
</div>
</div>
模态
function get_profil($slug = FALSE)
{
if ($slug === FALSE)
{
$query = $this->db->get($this->tbl_halaman);
return $query->result_array();
}
$query = $this->db->get_where($this->tbl_halaman, array('slug'=>$slug));
return $query->row_array();
}
请帮我做什么。谢谢
答案 0 :(得分:0)
应该是echo $dt
而不是echo $dt['slug']