PHP Classes

File: example_csv.php

Recommend this page to a friend!
  Classes of Ellery Leung   Create CSV   example_csv.php   Download  
File: example_csv.php
Role: Example script
Content type: text/plain
Description: Example
Class: Create CSV
Generate CSV files from MySQL query results
Author: By
Last change: Show new usage of quoting the CSV value.
Date: 16 years ago
Size: 689 bytes
 

Contents

Class file image Download
<?php
include("CreateCSV.class.php");
$conn = mysql_connect("localhost", "root", "");

$sql = "SELECT * FROM mysql.user";

#Thanks for nlstart's suggestions, now this class support quoted for CSV value.

//To print out the record without column heading and all values are quoted
print CreateCSV::create($sql);

//To print out the record without column heading and all values are NOT quoted
print CreateCSV::create($sql, false, false);

//To print out the record with column heading and all values are quoted
print CreateCSV::create($sql, true);

//To print out the record with column heading and all values are NOT quoted
print CreateCSV::create($sql, true, false);

?>