Location: PHPKode > scripts > rs2csv > rs2csv/example3.php
<?php
/*
Example 3
*/
require("rs2csv.class.php");
// Make your own database connection to the MySQL server and execute your SQL-query.
$link = mysql_connect("localhost", "root", "") or die("Could not connect : " . mysql_error());
mysql_select_db("mysql", $link) or die("Could not select database");    
$rs = mysql_query("SELECT * FROM user");

$csv = new rs2csv; // create a new instance of the rs2csv class.
$csv->set_fname("example3.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->process_rs($rs); // Process your resultset.
$csv->output_csv(); // Output the CSV file.
?>
Return current item: rs2csv