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??

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制