title: php codeigniter i want to redirect this function print_view and also pass the data
body: <p>php codeigniter i want to redirect this function print_view and also pass the data  <code>$this-&gt;db-&gt;insert('invoice_main',$datas);$result = $this-&gt;db-&gt;insert_id();</code></p>
  
  <pre><code>Public function insert_invoice(){
      $item_name = $_POST['item'];
       $rate = $_POST['rate'];
       $quantity = $_POST['quantity'];
       $tax = $_POST['tax'];
       $amount = $_POST['amount'];
       $invoice_id = $this-&gt;input-&gt;post('invoice_id');
       //$invoice_id++;
       $datas = array(
         'user_id' =&gt; $this-&gt;session-&gt;userdata('user_id'),
             'invoice_id' =&gt; $this-&gt;input-&gt;post('invoice_id'),
          'pt_opnum' =&gt; $this-&gt;input-&gt;post('pt_opnum'),
          'pt_uhid' =&gt; $this-&gt;input-&gt;post('pt_uhid'),
          'doc_name' =&gt; $this-&gt;input-&gt;post('doc_name'),
          'status'=&gt;1
         );
       $this-&gt;db-&gt;insert('invoice_main',$datas);
       $result = $this-&gt;db-&gt;insert_id();
       for ($i=0; $i &lt;count($item_name) ; $i++) {
         $data=array(
             'invoice_id' =&gt;$invoice_id,
             'pt_name'=&gt; $this-&gt;input-&gt;post('pt_opnum'),
             'date'=&gt;date('d-m-Y'),
             'name'=&gt;$item_name[$i],
             'rate'=&gt;$rate[$i],
             'quantity'=&gt;$quantity[$i],
             'tax'=&gt;$tax[$i],
             'amount'=&gt;$amount[$i],
             'sub_total'=&gt;$_POST['sub_total'],
             'o_tax'=&gt;$_POST['o_tax'],
             'grand_total'=&gt;$_POST['grand_total'],
             'status'=&gt;1
             );
         $this-&gt;db-&gt;insert('invoice_details',$data);
     }
     return($this-&gt;db-&gt;affected_rows()!=1)?false:true;
     $this-&gt;print_view($result);
  }
  
  public function print_view($result){
   redirect(base_url()."invoice/print_view/".$result);
   }
  </code></pre>