title: Passing variables from view to controller (MVC)
body: <p>In my view i have a foreach statement which grabs all the nessesary data from the database which displays correctly.</p>
  
  <p>Here is the view:</p>
  
  <pre><code>&lt;?php
  
  ?&gt;
  
      &lt;div class="cmt-container" &gt;
          &lt;?php
  
          foreach($results as $row){
              $user = $row-&gt;user;
              $comment = $row-&gt;comment;
              $date = $row-&gt;date;
              $name = $row-&gt;name;
              $joke = $row-&gt;joke;
              $joke_id = $row-&gt;joke_id;
  
              // Get gravatar Image
              // https://fr.gravatar.com/site/implement/images/php/
              $default = "mm";
              $size = 35;
              $grav_url = "http://www.gravatar.com/avatar/"."?d=".$default."&amp;s=".$size;
  
              ?&gt;
  
              &lt;div class="cmt-cnt"&gt;
                  &lt;img src="&lt;?php echo $grav_url; ?&gt;" /&gt;
                  &lt;div class="thecom"&gt;
                      &lt;h5&gt;&lt;?php echo $user; ?&gt;&lt;/h5&gt;&lt;span data-utime="1371248446" class="com-dt"&gt;&lt;?php echo $date; ?&gt;&lt;/span&gt;
                      &lt;br/&gt;
                      &lt;p&gt;
                          &lt;?php echo $comment; ?&gt;
                      &lt;/p&gt;
                  &lt;/div&gt;
              &lt;/div&gt;&lt;!-- end "cmt-cnt" --&gt;
  
  
          &lt;?php
  
          }
          ?&gt;
  
  &lt;?php
  
  echo form_open('comments/insertComment');
  
  ?&gt;
          &lt;div class="new-com-bt"&gt;
              &lt;span&gt;Write a comment ...&lt;/span&gt;
          &lt;/div&gt;
  
          &lt;div class="new-com-cnt"&gt;
              &lt;input type="text" id="name-com" name="name-com" value="" placeholder="Name is optional" /&gt;
              &lt;textarea class="the-new-com" id="the-new-com" name="the-new-com" placeholder="Write your comment here..."&gt;&lt;/textarea&gt;
              &lt;input type="hidden" name="joke_id"&gt;
              &lt;input class="bt-add-com" type="submit" value="Post comment"&gt;
              &lt;div class="bt-cancel-com"&gt;Cancel&lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="clear"&gt;&lt;/div&gt;
      &lt;/div&gt;&lt;!-- end of comments container "cmt-container" --&gt;
  
  &lt;?php
  
  echo form_close();
  
  ?&gt;
  </code></pre>
  
  <p>My question is, how can i pass the $joke_id variable to the insertComment function in my comments controller.</p>
  
  <p>I have put the input field as hidden on the joke_id field because i want to assign the ID of a joke to a comment, so the joke will have unique comments.</p>