csv_terminated $ = " n"-csv_separator $ = ","-
$ csv_enclosed = '"'-
csv_escaped $ = "\"-
$ query = "select * from table de $"-
$ result = mysql_query ($ query) -
$ rowcount = mysql_num_fields ($ result) -
$ data = '' -
for ($ i = 0 $ i lt; rowcount- $ $ i ++) {
$ l = $ csv_enclosed. str_replace (csv_enclosed $, $ csv_escaped. csv_enclosed $,
stripslashes (mysql_field_name ($ result, $ i))). $ csv_enclosed-
$ data. = $ l-
$ data. = $ csv_separator-}
$ output = trim (substr ($ data, 0, -1)) -
$ output. = $ csv_terminated-
while ($ row = mysql_fetch_array ($ result)) {
$ data = '' -
for ($ j = 0 $ j lt; fields_cnt- $ $ j ++) {
if ($ row [$ i] == '0' || $ row [$ j]! = '') {
if ($ csv_enclosed == '') {. $ data = $ row [$ j] -}
else {$ data. = $ csv_enclosed. str_replace (csv_enclosed $, $ csv_escaped. csv_enclosed $, $ row [$ i]). $ csv_enclosed-}}
else {$ data = '' -.}
if ($ j lt; rowcount $ - 1) {$ data = $ csv_separator-.}}
$ output. = $ schema_insert-
$ output. = $} csv_terminated-
entête("Cache-Control: doit-revalidate, post-check = 0, pré-check = 0") -
entête("Content-Length: " . strlen ($ output)) -
// Sortie au navigateur avec le type MIME approprié, vous choisissez -)
entête("Content-Type: text / x-csv") -
//entête("Content-type: text / csv") -
//entête("Content-type: text / csv") -
entête("Content-Disposition: filename = Fixation- $ filename") -
echo $ output-
Sortie-