php - Undefined variable id in CodeIgniter -
i have todo list project.
my model
class model_lists extends ci_model { function model_list(){ parent::__construct(); } function list_get($id){ $this->load->database(); $query = $this->db->get_where('lists', array('id'=>$id)); return $query->row_array(); }
my controller
public function view_list($id){ $this->load->model('model_lists'); $data["query"] = $this->model_lists->list_get($id); $this->load->view('lists/view_list',$data); }
list view
<?php echo $query['list_by']; ?>
however, when access view 2 php errors
1) message: missing argument 1 lists::view_list()
2) message: undefined variable: id
this how call list:
<a class="view_list" href="<?php echo site_url("lists/view_list?lid={$row->list_id}");?>"><i class="icon-eye"> </i></a>
your site url not correct. error because no id being passed , in ci (unless have set use query arrays) url of format www.example.com/controller/method/argument
so try:
href="<?php echo site_url('lists/view_list/'.$row->list_id); ?>"
in docs: http://www.codeigniter.com/user_guide/helpers/url_helper.html#site_url
Comments
Post a Comment