Friday 7 June 2013

Export CSV file in PHP

  header("Content-type:text/octect-stream");
  header("Content-Disposition:attachment;filename=data.csv");
 $recordlist = $this->db->query("SELECT * FROM `table` ");

        foreach($recordlist ->result_array() as $row)
        {
            print '"' . stripslashes(implode('","',$row)) . "\"\n";
        }
        exit;

No comments:

Post a Comment