2016-11-13 10:10 浏览 55


I have this todo list project.

My model

class Model_lists extends CI_Model {

function Model_list(){

function list_get($id){
    $query = $this->db->get_where('lists', array('id'=>$id));
    return $query->row_array();

My Controller

public function view_list($id){
    $data["query"] = $this->model_lists->list_get($id);

List view

 echo $query['list_by'];

However, when I access the view I get 2 PHP errors

1) Message: Missing argument 1 for Lists::view_list()
2) Message: Undefined variable: id

This is how I call the list:

<a class="view_list" href="<?php echo site_url("lists/view_list?lid={$row->list_id}");?>"><i class="icon-eye"> </i></a>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答 默认 最新

  • 已采纳
    dongti8535 dongti8535 2016-11-13 14:24

    Your site url is not correct. The error is because no id is being passed and in CI (unless you have set to use query arrays) then the url is of the format

    So try:

    href="<?php echo site_url('lists/view_list/'.$row->list_id); ?>"

    In the docs:

    点赞 评论 复制链接分享