title: How to put MySQL table into session variable and using the table on next page?
body: <p>I have two PHP pages. On page1 a <strong>temporary</strong> table is created and filled with data from a mysql database. I am trying to store this table into a $_SESSION variable so that I can put the table onto page2.</p>
  
  <p>Right now this has been my approach:</p>
  
  <p>This is (part) of the code on page1:</p>
  
  <pre><code>ob_start();
  session_start();
  
    //Select data from temporary table
  $result = mysqli_query($mysqli,"SELECT * FROM table");
  
  
  //store table into session variable
  $_SESSION['fase1result'] = $result;
  </code></pre>
  
  <p>This is the code on page2:</p>
  
  <pre><code>ob_start();
  session_start();
  
  $table = $_SESSION['fase1result'];
  
  echo "&lt;table border='1'&gt;
  &lt;tr&gt;
  &lt;th&gt;ProductID&lt;/th&gt;
  &lt;th&gt;ProductName&lt;/th&gt;
  &lt;th&gt;Fase1&lt;/th&gt;
  &lt;/tr&gt;";
  
  while($row = mysqli_fetch_array($table))
  {
  echo "&lt;tr&gt;";
  echo "&lt;td&gt;" . $row['ProductID'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['ProductName'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['Fase1'] . "&lt;/td&gt;";
  echo "&lt;/tr&gt;";
  }
  echo "&lt;/table&gt;";
  </code></pre>
  
  <p>Unfortunately, up until now these scripts return me an error on page2. At this moment, the echoing of the table on page2 is just to test and verify that the table is actually passed on. At a later moment I want to be able to use MySQL queries to further add data to the table. Hope you could help me.</p>
  
  <p>UPDATE:<br>
  Error that I'm getting is:</p>
  
  <pre><code>Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in domain/page2.php on line 32
  </code></pre>
  
  <p>With line 32 in page2 being:</p>
  
  <pre><code>while($row = mysqli_fetch_array($table))
  </code></pre>
  
  <p>To better explain my question, I have posted another question which can be found here:
  <a href="https://stackoverflow.com/questions/23130150/modifying-mysql-table-on-different-pages-with-scores-from-a-html-form">Modifying MySQL table on different pages with scores from a HTML form</a></p>