Login   Register  
PHP Classes
elePHPant
Icontem

File: example3.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  >  example3.php  >  Download  
File: example3.php
Role: Example script
Content type: text/plain
Description: Example script 3
Class: rs2csv
Convert a MySQL record set to a CSV file.
Author: By
Last change:
Date: 2003-06-22 20:52
Size: 905 bytes
 

Contents

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