recently I've been trying to figure out this issue. Imagine a page with few links, each link is generated using a query that retrieves all the links from my DB
. What I'm trying to do is when I click the link it loads a detail page of that exact link's ID within the detail
view. Instead I'm getting the url with the ID attached to it. I think that this .$row->id
is what's causing it, but I don't know how else to pass the ID to the controller. Below is my code.. Thank you in advance for reading and possibly helping.
detail_v
result() as $row): ?> id) ?>" target="_blank" class="mosaic-overlay">
controller
public function detail($id) {
$this->load->model('Core_m');
$page =$this->Page_model->get_page_by_id($id);
$this->load->view('detail_v');
}
Core_m
public function get_page_by_id($id) {
$query = $this->db->query("SELECT * FROM (`page`) WHERE `id` = \"$id\" LIMIT 1");
if ($query->num_rows() > 0)
{
return $query->row();
}
return false;
}
Also a second thing I can't seem to figure out is why clicking the link opens a new browser window instead of just forwarding to the new URL within the same window. Please if you have any ideas on how to solve either of these issues please let me know. All help is much appreciated.