Login   Register  
PHP Classes
elePHPant
Icontem

File: example2.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Sean Natoewal  >  rs2csv  >  example2.php  >  Download  
File: example2.php
Role: Example script
Content type: text/plain
Description: Example script 2
Class: rs2csv
Convert a MySQL record set to a CSV file.
Author: By
Last change:
Date: 2003-06-22 20:52
Size: 858 bytes
 

Contents

Class file image Download
<?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.
?>