title: Passing Info From One View to Another
body: <p><strong>EDIT 1.</strong>
  The results of a query from my database are displayed on my view page. Next to each unique result is a button:</p>
  
  <pre><code>// first_view.php    
  &lt;?php echo form_open('controller/method'); ?&gt;
  &lt;?php foreach($results_found as $item): ?&gt;
  &lt;p&gt;&lt;?php echo $item-&gt;name ?&gt;&lt;/p&gt;
  &lt;p&gt;&lt;?php form_submit('buy','Buy This'); ?&gt;&lt;/p&gt;
  </code></pre>
  
  <p>When a user clicks on one of these buttons (lets say button 4), I would like to display the user's choice from the array onto another view.</p>
  
  <p>I've tried using this:</p>
  
  <pre><code> // first_view.php
  &lt;?php echo $this-&gt;session-&gt;set_userdata('choice',$item); ?&gt;
  </code></pre>
  
  <p>immediately before</p>
  
  <pre><code>// first_view.php    
  &lt;?php echo form_close(); ?&gt;
  </code></pre>
  
  <p>thinking that the user's final choice would be stored there so I can display it on another view like this:</p>
  
  <pre><code>// second_controller.php
  $c = $this-&gt;session-&gt;userdata('choice');
  
  
  // second_view.php
  echo 'Your Choose: '. $c;
  </code></pre>
  
  <p>However, what actually displays is the last result displayed on first_view.php, not what the user choose. </p>
  
  <p>My question is, if the user clicked on button 4, how do I get that particular choice displayed onto another view?</p>
  
  <p><strong>END OF EDIT1</strong></p>
  
  <p><strong>ORIGINAL QUESTION</strong></p>
  
  <p>My view page (CodeIgniter) displays the contents of an array in the form of several links. If a user clicks on a link, I want the user to be taken to another view page (via a controller) that gives more information concerning that particular link (which is stored in that particular position in the array)</p>
  
  <p>My question is, how do I access and display the contents of that particular location within the array on the second view file without getting a "Undefined variable error" on the second view?</p>
  
  <p>Here is what I am trying to do in code form</p>
  
  <pre><code>// my_controller.php
  $array_name['variable_name'];
  $this-&gt;load-&gt;view('first_view.php');
  
  // first_view.php
  &lt;?php foreach($variable_name as $vn): ?&gt;
  &lt;?php echo anchor('controller_name' $vn-&gt;info ?&gt; // if user clicks on 3rd link
  &lt;?php endforeach ?&gt;                              // I want to beable to access
                                                   // index 2 of the array in the 
                                                   // second view file so I can 
                                                   // display more info 
  // second_view.php
  &lt;?php $vn[2]-&gt;info ?&gt;
  </code></pre>