I'm new in CodeIgniter. I'm having a problem fetching "id" from "project view" then i will pass it to another view which a call "project details view". I've tried using ampersand (&) in URL and i guess that does not work in CodeIgniter.
Here are my codes:
In my controller:
public function project(){
$data["title"] = "CodeIgniter Projects";
$this->load->model("projects_model");
$data["result"] = $this->projects_model->getProjects();
$this->load->view("project", $data);
}
public function project_details($project_id){
$this->load->model("projects_model");
$data["result"] = $this->projects_model->getProjectDetails($project_id);
$this->load->view("project_details", $data);
}
for my model
function getProjects(){ $query = $this->db->query("SELECT * FROM projects"); return $query->result(); } function getProjectDetails($project_id){ $this->db->where('project_id', $project_id); $query = $this->db->get('projects'); }
in my view i only use < a href="controller/project_details">< / a>
to call the project details view.
You can pass anything to controller from a view as a uri_segment. The general syntax is,
Controller/function/parameter
Here, in your case
controller/project_details/<?php echo $project_id; ?>