我有两个ID: - $ blog_id和$ comments_id。我想使用$ comments_id更新表(tbl_comments),其中$ blog_id重定向到上一页,即; $ blog_id页面
我怎样才能传递这些ID? 这是我的代码:
查看
<a href="<?php echo base_url(); ?>comment_management/change_to_published/<?php echo $comments_id; ?>/<?php echo $comments_id; ?>"> <?php echo 'Published me'; ?> </a>
是对的吗?
或建议我其他
控制器
public function change_to_published($blog_id,$comments_id) {
$this->comments_mgt_model->change_to_published_comments($comments_id);
redirect('comment_management/index/'.$blog_id);
}
模型:
public function change_to_published_comments($comments_id) {
$this->db->select('*');
$this->db->from('tbl_comments');
$this->db->where('comments_id', $comments_id);
$this->db->set('comments_status', 1);
$this->db->update('tbl_comments');
}
请帮助我。
*注意:我的主要问题是将id传递给控制器并使用函数change_to_published()*