title: php - how can i refresh session variables each time when query executes
body: <p>I have a search bar,when user search something through search bar a query get executed and some results appear on screen.</p>
  
  <p>I am storing all info related to the result in multidimensional <code>session</code> array.  </p>
  
  <p>each result has link,when user click on this link new page opens which display whole info for that result.  </p>
  
  <p>search result depend on the term entered by user.  </p>
  
  <p>my problem is: suppose when first time user enter some term it got 4 results,al info related to these 4 results get stored in session array,but next time if user search again different result will appear but session array still has the same old value,because of this when next page open it shows different info of that result(it shows info based on last result's indexes).  </p>
  
  <p>My code is :  </p>
  
  <pre><code>&lt;?
  while($row = mysqli_fetch_array($sql))
  {   
      $title = $row['title'];
      $description = $row['description'];
      $url = $row['content_url'];
      $icon = $row['thumb_icon_url'];
  ?&gt;
  &lt;?php
  $_SESSION['result'][$id]  = Array('title' =&gt; $title,'description'=&gt; $description,'content_url' =&gt; $url,'icon' =&gt; $icon,'id'=&gt; $id);
  ?&gt;
  </code></pre>
  
  <p>code for new page:  </p>
  
  <pre><code>&lt;?php
  if(isset($_GET['id']))
  {
      $id = $_GET['id'];
      ?&gt;   
      &lt;div id="iframe" class="embed-responsive embed-responsive-16by9 col-md-9"&gt;                      
          &lt;iframe  class="embed-responsive-item item" src="https://docs.google.com/gview?url=&lt;?php echo $_SESSION['result'][$id]['content_url'];?&gt;&amp;embedded=true#toolbar=0&amp;navpanes=0&amp;scrollbar=0" frameborder="0"&gt;&lt;/iframe&gt;
      &lt;/div&gt;
      &lt;?php
  }?&gt;
  </code></pre>