简体   繁体   中英

How do I pass link ID to controller?

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.

using `target="_blank"` opens a new browser window 

<?php echo base_url('core/detail/'.$row->id) ?>查找/ ..帮助了吗?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM