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
|
<?php
header('Content-Type: text/csv;');
header('Content-Disposition: attachment; filename="test.csv"');
// This is an example of config.php
$dbhost = '*****';
$dbuser = '*****';
$dbpass = '*****';
$dbname = '*****';
// This is an example opendb.php
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);
$req=mysql_query("SELECT id_formation, titre_formation, cout FROM form_formations");
?>"Id";"Titre";"Cout"<?php
for ($i=0;$i<mysql_num_rows($req);$i++){
echo "\n".'"'.mysql_result($req,$i,"id_formation").'";"'.mysql_result($req,$i,"titre_formation").'";"'.mysql_result($req,$i,"cout").'"';
}
?> |