title: export all the data into excel sheet of a particular user who has logged using php and Mysql
body: <p>I want to export only those records which a particular  user has entered. For example: I have logged in by user id - user_test and i have few records which i have entered. for the same when the record is saved into the database my login name is also being saved along with the record. When i want to fetch and display the data of the particular user in session its working fine. but when i am using the same query for downloading the report i am not getting any error, the page is getting download with blank fields. Here is the code i am using for downloading the records in excel sheet. </p>
  
  <pre><code>&lt;?php
  include_once 'classes/admin-class.php';
  $admin = new itg_admin();
  $admin-&gt;_authenticate();
  $ten = $_SESSION['admin_login'];
  ?&gt;
  &lt;?php
      $host="localhost";
      $username="root";
      $password="";
      $dbname="kuidfc_project_monitoring";
      $con = new mysqli($host, $username, $password,$dbname); 
  
      $sql_data="SELECT * from user_daily_records WHERE users = '" . $admin-&gt;get_nicename() . "';";
      $result_data=$con-&gt;query($sql_data);
      $results=array();
      $filename = "Daily_Report.xls"; // File Name
      // Download file
      header("Content-Disposition: attachment; filename=\"$filename\"");
      header("Content-Type: application/vnd.ms-excel");
  
      $flag = false;
      while ($row = mysqli_fetch_assoc($result_data)) {
          if (!$flag) {
              // display field/column names as first row
              echo implode("\t", array_keys($row)) . "\r\n";
              $flag = true;
          }
          echo implode("\t", array_values($row)) . "\r\n";
      }
      ?&gt;
  </code></pre>