Location: PHPKode > scripts > rs2csv > rs2csv/example2.php
<?php
/*
Example 2
*/
require("rs2csv.class.php");
// Make your own database connection to the MySQL server.
$link = mysql_connect("localhost", "root", "") or die("Could not connect : " . mysql_error());
mysql_select_db("mysql", $link) or die("Could not select database");    

$csv = new rs2csv; // create a new instance of the rs2csv class.
$csv->set_fname("example2.csv"); // Set the filename for download. Default is 'filename.csv'.
$csv->set_ctype("application/octet-stream"); // Set the content-type for download. Default is 'text/tab-separated-values'.
$csv->set_cdisp("attachment"); // Set the content-disposition for download. Default is 'attachment'.
$csv->set_sep(";"); // Set the seperator sign. Default is ','.
$csv->exec_sql("SELECT * FROM user", $link); // Execute your SQL-query.
$csv->output_csv(); // Output the CSV file.
?>
Return current item: rs2csv