PHP Classes

File: example1.php

Recommend this page to a friend!
  Classes of Sean Natoewal   rs2csv   example1.php   Download  
File: example1.php
Role: Example script
Content type: text/plain
Description: Example script 1
Class: rs2csv
Convert a MySQL record set to a CSV file.
Author: By
Last change:
Date: 21 years ago
Size: 722 bytes


Class file image Download
Example 1
$csv = new rs2csv; // create a new instance of the rs2csv class.
$csv->set_fname("example1.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->make_con("localhost", "root", "", "mysql"); // Open a database connection to the MySQL server.
$csv->exec_sql("SELECT * FROM user"); // Execute your SQL-query.
$csv->output_csv(); // Output the CSV file.