csv.lib.php - main library
dbmysql.class.php - class for working with mysql database
Example of using:
<?php
require_once("csv.lib.php");
require_once("dbmysql.class.php");
define("DB_NAME", "mysql");
define("DB_HOST", "localhost");
define("DB_USER", "root");
define("DB_PASS", "");
$db = new DbMySQL(DB_HOST, DB_NAME, DB_USER, DB_PASS);
$db->connect();
$cvs_array = $db->select("SELECT
*
FROM
mysql.user
");
$db2csv = new export2CSV(",","\n");
$csv = $db2csv->create_csv_file($cvs_array);
header("Content-type: application/eml");
header("Content-Disposition: attachment; filename=mysql_users.csv");
echo $csv;
?>




