CodeIgniter如何为视图页面提供动作URL

I have CodegIniter system for displaying products. When a products view page is executed through a url like

localhost/project/index.php/product/view/102

I want to add an option to add comment for particular product in this page, but how can I give

$data['action'] = site_url('product/prodcutView');

This what I have tried so far, but it didn't save value , i tihnk action url is not correct, please advice.

function addComment() {

    // set common properties
    $data['title'] = 'Add new comment';
    $data['action'] = site_url('/product/ProductView');


    // set empty default form field values
    $this -> _set_fields();
    // set validation properties
    $this -> _set_rules();

    // run validation
    if ($this -> form_validation -> run() == FALSE) {

         log_message('debug', 'comment save failed.');

    } else {
        // save data
        $comment = array(
        'product_id' => $this -> input -> post('product_id'),
         'comment' => $this -> input -> post('comment'), 
         'review' => $this -> input -> post('review'), 
         );
        $category_id = $this -> Comment_model -> save($comment);


    }

    // load view
    $this -> load -> view('/product/ProductView', $data);
}

You could try using uri segments make sure your site url link is correct and matches what you have in url.

localhost/project/index.php/product/view/102

Testing echo out $this->uri->segment(3) and see what number shows.

if ($this->uri->segment(3) == FALSE) {
  $data['action'] = site_url('product/view');
} else {
  $data['action'] = site_url('product/view') .'/'. $this->uri->segment(3);
}

You can store it in array and give that var to view like this $this->load->view('product_view',$data); Here $data is contain prod_id in your case. like this $data['prod_id']=$result[0]['prod_id'];