title: Adding dynamic id in the url using codeigniter
body: <p>I have an edit page with url</p>
  
  <pre><code>example.com/product/edit/11
  </code></pre>
  
  <p>Now if the validation is false I intend to reload the edit page but can't figure how to add that id '11' in the url</p>
  
  <p>Things I have done so far</p>
  
  <p>In routes.php</p>
  
  <pre><code>$route['product/edit/(:num)'] = "product/edit/$1";
  </code></pre>
  
  <p>Now how do I pass that id in the url from the controller</p>
  
  <p>I tried this</p>
  
  <pre><code>$this-&gt;load-&gt;view('product/edit/'.$edit_id,$data);
  </code></pre>
  
  <p>Edit: I am not trying to pass edit_id to the view file</p>
  
  <p>I am trying to simulate this:</p>
  
  <pre><code>&lt;a href="example.com/product/edit/11"&gt;Edit&lt;/a&gt;
  </code></pre>
  
  <p>So that the function in my controller</p>
  
  <pre><code>function edit($edit_id)
  {
  //some code
  }
  </code></pre>
  
  <p>Will have have that <code>$edit_id</code> to work with</p>
  
  <p>It didn't work as I suspected.</p>
  
  <p>I know I can pass that id to the view file and make it work, but I wanted to if I can pass that id in the url.</p>
  
  <p>Thanks</p>
  
  <p>Edit: I figured that even if I managed to pass it in the url. I will end up with more problem like setting the form attributes and other stuff. What I did was</p>
  
  <pre><code>redirect('product/edit/'.$edit_id);
  </code></pre>
  
  <p>and gave an error message by setting the <code>flashdata</code>.</p>