Bonjour,

Je voudrais exporter une table ACCESS au format csv en utilisant php. Essayé de faire un code, mais ça me génère un fichier csv vide .
Je vois pas où est mon erreur. Si quelqu'un pouvait m'aider ça serait bien, je sèche complètement.

Voici mon code php :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$fname = "tracking.csv" ;
$html_output = '';
 
$sqlcsv = " SELECT * FROM banque";
 
if (false === $result = odbc_exec($cnx, $sqlcsv)) die('Impossible de générer le fichier, voici l\'erreur :'.mysql_error());
 
 
$num_fields = odbc_num_fields($result);
 
/*for ($i = 0; $i < $num_fields; $i++) {
  $html_output.= odbc_field_name($result , $i).",";
}*/
$html_output = substr($html_output,0, -1)."\r\n";
 
while($row = odbc_fetch_row($result)){
  for ($i=0; $i < $num_fields; $i++) {
    $html_output.= $row[$i]."|";
 
  }
  $html_output = substr($html_output,0, -1)."\r\n";
}
 
header('Content-Type: text/csv'); 
header('Content-Disposition: attachment; filename="tracking.csv"');
header('Pragma: no-cache');
header('Expires: 0');
 
echo $html_output;
Est que quelqu'un aurait une idée pourquoi j'ai un fichier csv vide ?
Merci.