Login   Register  
PHP Classes

File: example_csv.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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: 7 years ago
Size: 689 bytes


Class file image Download
$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($sqlfalsefalse);

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

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