dongyuan1984
2013-12-05 11:44
浏览 27
已采纳

如何将链接ID传递给控制器​​?

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.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douliang4858 2013-12-05 11:51
    已采纳
    using `target="_blank"` opens a new browser window 
    

    And <?php echo base_url('core/detail/'.$row->id) ?> Look for / .. Helped??

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题