title: How to generate a csv without adding to a table in php
body: <p>im currently generating a csv file througha php script, this happens after a chain of events as i have shown below</p>
  
  <p><img src="https://i.stack.imgur.com/Xyrro.png" alt="enter image description here"></p>
  
  <p>but now i have a requirement to generate the csv without adding it to a table, first of all is it possible?? if so can you please assist me on this</p>
  
  <p>my php code to add to table</p>
  
  <pre><code>    &lt;?php
  
  $table_count = mysql_query("SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = 'bookers' AND table_name LIKE 'b_table_%' ");
  
  while($row = mysql_fetch_array($table_count)){
  
  $table = $row["TABLE_NAME"];
  
  $query = ("CALL Dummy_2('{$table}')");
  $excute = mysql_query($query);
  ?&gt;
  </code></pre>
  
  <p>the dummy_2 sp</p>
  
  <pre><code>BEGIN   
  
  SET @sqlstring = CONCAT("INSERT INTO report(ID, name, accountname, accountID, status, count, earliest_booking,recent_booking)
  SELECT  DISTINCT b.ID, name, name, c.ID, status, total_impr, min(a.timestamp), max(a.timestamp)
  FROM    ",b_table," a INNER JOIN bookers b on a.ID = b.ID INNER JOIN accounts c on b.accountID = c.accountID
  
  WHERE   a.timestamp &gt; DATE_ADD(NOW(), INTERVAL -3 YEAR)
  GROUP BY ID;");
      PREPARE stmt FROM @sqlstring;
      EXECUTE stmt;
  
  END$$
  </code></pre>
  
  <p>my php code to generate csv</p>
  
  <pre><code>require 'exportcsv.inc.php';
  
  $table="report"; // this is the tablename that you want to export to csv from mysql.
  
  exportMysqlToCsv($table);
  </code></pre>
  
  <p>can put the exportcsv.inc.php too if needed</p>
  
  <p><strong>P.S - Is there a possibility where i could create a temporary table and insert the data to the csv</strong></p>