title: Export to CSV not same as table PHP
body: <p>I am trying to download table data into a CSV format. The data in one of the fields contains ",". 
  Eg: Doe, John</p>
  
  <p>When I download the csv file, the data after comma is shifted to next column. But I want the entire data i.e including comma in same column.</p>
  
  <p>The Code I used as follows:</p>
  
  <pre><code>&lt;?php
  include('dbconfig.php');
  //header to give the order to the browser
  header('Content-Type: text/csv');
  header('Content-Disposition: attachment;filename=download.csv');
  //select table to export the data
  $sql ="SELECT * FROM tablename";
  $select_table=mysqli_query($db, $sql);
  $rows = mysqli_fetch_assoc($select_table);
  
  if ($rows)
  {
  getcsv(array_keys($rows));
  }
  while($rows)
  {
   getcsv($rows);
   $rows = mysqli_fetch_assoc($select_table);
   }
  
    // get total number of fields present in the database
   function getcsv($no_of_field_names)
   {
     $separate = '';
  
  
    // do the action for all field names as field name
    foreach ($no_of_field_names as $field_name)
   {
   if (preg_match('/\\r|\\n|,|"/', $field_name))
   {
    $field_name = '' . str_replace('&lt;em&gt;', '', $field_name) . '';
    }
    echo $separate . $field_name;
  
   //sepearte with the comma
   $separate = ',';
    }
  
  //make new row and line
  echo "\r\n";
  }
  ?&gt;
  </code></pre>
  
  <p>Can someone help me get through this issue.
  Thanks</p>