title: Select data from database when i click the submit button
body: <p>i have a table when i want to click a button it get data from database to table i try this code but i get error.</p>
  
  <pre><code>    &lt;div class="wrapper wrapper-content animated fadeInRight"&gt;
              &lt;div class="row"&gt;
                  &lt;div class="col-lg-12"&gt;
                  &lt;div class="ibox float-e-margins"&gt;
                      &lt;div class="ibox-title"&gt;
                          &lt;h5&gt;Conference Table&lt;/h5&gt;
                          &lt;div class="ibox-tools"&gt;
                              &lt;a class="collapse-link"&gt;
                                  &lt;i class="fa fa-chevron-up"&gt;&lt;/i&gt;
                              &lt;/a&gt;
                              &lt;a class="dropdown-toggle" data-toggle="dropdown" href="table_data_tables.php#"&gt;
                                  &lt;i class="fa fa-wrench"&gt;&lt;/i&gt;
                              &lt;/a&gt;
                              &lt;ul class="dropdown-menu dropdown-user"&gt;
                                  &lt;li&gt;&lt;a href="table_data_tables.php#"&gt;Config option 1&lt;/a&gt;
                                  &lt;/li&gt;
                                  &lt;li&gt;&lt;a href="table_data_tables.php#"&gt;Config option 2&lt;/a&gt;
                                  &lt;/li&gt;
                              &lt;/ul&gt;
                              &lt;a class="close-link"&gt;
                                  &lt;i class="fa fa-times"&gt;&lt;/i&gt;
                              &lt;/a&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  
                      &lt;div class="ibox-content"&gt;
                                                      &lt;div class="form-group"&gt;
                                      &lt;div class="col-sm-4 col-sm-offset-5"&gt;
                                          &lt;button class="btn btn-white" type="submit"&gt;Cancel&lt;/button&gt;
                                          &lt;button class="btn btn-primary" type="submit"&gt;Run Report&lt;/button&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                          &lt;table class="table table-striped table-bordered table-hover dataTables-example" &gt;
                              &lt;thead&gt;
                                  &lt;tr&gt;
                                      &lt;th&gt;No&lt;/th&gt;
                                      &lt;th&gt;Aim&lt;/th&gt;
                                      &lt;th&gt;Date&lt;/th&gt;
                                      &lt;th&gt;Funded&lt;/th&gt;
                                      &lt;th&gt;Male&lt;/th&gt;
                                      &lt;th&gt;Female&lt;/th&gt;
                                      &lt;th&gt;Disabled&lt;/th&gt;
                                      &lt;th&gt;Total&lt;/th&gt;
                                      &lt;th&gt;Comments&lt;/th&gt;
                                      &lt;th&gt;Action&lt;/th&gt;
                                  &lt;/tr&gt;
                              &lt;/thead&gt;
                              &lt;tbody&gt;
                              &lt;?php
  $mysqli = new mysqli( 'localhost', 'user2', 'password', 'database' );
  
  
  if (mysqli_connect_error()) {
      echo mysqli_connect_error();
      exit();
  } 
  
             if (isset($_POST['submit'])) {
                  $query = 'SELECT * FROM conference';
                  $data = mysqli_query($mysqli, $query) ;
  
                  if (!$data) {
                      echo("Error description: " . mysqli_error($mysqli));
                  } else {
  
                      while ($row = mysqli_fetch_array($data)) {
                          echo "&lt;tr&gt;
                              &lt;td&gt;" . $row['NOTW'] . "&lt;/td&gt;
                              &lt;td&gt;" . $row['Aim'] . "&lt;/td&gt;
                              &lt;td&gt;" . $row['date'] . "&lt;/td&gt;
                              &lt;td&gt;" . $row['Funded'] . "&lt;/td&gt;
                              &lt;td&gt;" . $row['Male'] . "&lt;/td&gt;
                              &lt;td&gt;" . $row['Female'] . "&lt;/td&gt;
                              &lt;td&gt;" . $row['Disabled'] . "&lt;/td&gt;
                              &lt;td&gt;" . $row['Total'] . "&lt;/td&gt;
                              &lt;td&gt;" . $row['Comments'] . "&lt;/td&gt;
                              &lt;td&gt;   Edit   Trush  &lt;/td&gt;                                           
                            &lt;/tr&gt;";
                       }
                   }
              }
                      ?&gt;
                              &lt;/tbody&gt;
                              &lt;tfoot&gt;
                              &lt;/tfoot&gt;
                          &lt;/table&gt;
                      &lt;/div&gt;
              &lt;/div&gt;
              &lt;/div&gt;
  </code></pre>
  
  <p>the Error is </p>
  
  <blockquote>
    <p>Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result,
    null given in /home/cshrnaf/public_html/MIS_CSHRN/reporttest.php on
    line 265</p>
  </blockquote>
  
  <p>265 line:</p>
  
  <pre><code> while($row = mysqli_fetch_array($data))
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>After Change code to: </p>
  
  <pre><code>&lt;div class="ibox-content"&gt;
                          &lt;table class="table table-striped table-bordered table-hover dataTables-example" &gt;
                              &lt;thead&gt;
                                  &lt;tr&gt;
                                      &lt;th&gt;No&lt;/th&gt;
                                      &lt;th&gt;Aim&lt;/th&gt;
                                      &lt;th&gt;Date&lt;/th&gt;
                                      &lt;th&gt;Funded&lt;/th&gt;
                                      &lt;th&gt;Male&lt;/th&gt;
                                      &lt;th&gt;Female&lt;/th&gt;
                                      &lt;th&gt;Disabled&lt;/th&gt;
                                      &lt;th&gt;Total&lt;/th&gt;
                                      &lt;th&gt;Comments&lt;/th&gt;
                                      &lt;th&gt;Action&lt;/th&gt;
                                  &lt;/tr&gt;
                              &lt;/thead&gt;
                              &lt;tbody&gt;
                              &lt;?php
  $mysqli = new mysqli( 'localhost', 'user2', 'password', 'database' );
  
  
  if (mysqli_connect_error()) {
      echo mysqli_connect_error();
      exit();
  } 
  /*
  if(isset($_POST['submit']))
  {
      */
  $query = 'SELECT * FROM conference';
  $data = mysqli_query($mysqli, $query);
  
  
                      while($row = mysqli_fetch_array($data)) 
                      {
                          echo "  &lt;tr&gt;
                                      &lt;td&gt;" . $row['NOTW'] . "&lt;/td&gt;
                              &lt;td&gt;" . $row['Aim'] . "&lt;/td&gt;
                              &lt;td&gt;" . $row['date'] . "&lt;/td&gt;
                              &lt;td&gt;" . $row['Funded'] . "&lt;/td&gt;
                              &lt;td&gt;" . $row['Male'] . "&lt;/td&gt;
                              &lt;td&gt;" . $row['Female'] . "&lt;/td&gt;
                              &lt;td&gt;" . $row['Disabled'] . "&lt;/td&gt;
                              &lt;td&gt;" . $row['Total'] . "&lt;/td&gt;
                              &lt;td&gt;" . $row['Comments'] . "&lt;/td&gt;
                              &lt;td&gt;   Edit   Trush  &lt;/td&gt;  
  
                                  &lt;/tr&gt;";
                      }
  //}
                      ?&gt;
                              &lt;/tbody&gt;
                              &lt;tfoot&gt;
                              &lt;/tfoot&gt;
                          &lt;/table&gt;
                      &lt;/div&gt;
              &lt;/div&gt;
              &lt;/div&gt;
  </code></pre>
  
  <p>data will be loaded if the page will be loaded</p>