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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| <?php
if (isset($_POST["msg"]))
{
$msg= $_POST["msg"];
}
else
{
$msg="";
}
function recbase($table)
{
$file = fopen("./exportation/$table.csv", "w");
if (!$file)
{
print'<p>Impossible d ouvrir un fichier distant en écriture.\n';exit;}
$req = mysql_db_query("vos","select * from `$info`");
$ligne1=true;
while($row = mysql_fetch_array($req)) // début d'écriture de l'indice
{
if ($ligne1)
{
for($j=0;$test=each($row);$j++)
{
if($j%2) fwrite($file,"\"$test[0]\";");
}
$ligne1=false;
}
} // fin d'écriture de l'indice
fwrite($file,"\n");
$req = mysql_db_query("vos","select * from `info`");
while($row = mysql_fetch_array($req)) // début d'écriture des valeurs
{
if (!$ligne1)
{
for($j=0;$test=each($row);$j++)
{
$champ=trim(str_replace("\n","",$test[1]));
if($j%2) fwrite($file,"\"$champ\";");
}
}
fwrite($file,"\n");
} // début d'écriture des valeurs
fclose($file);
mysql_free_result($req);
return "télécharger la table :$table:<br>";
}
require "config.php";
$entete="EXPORTATION TERMINEE<br><br>";
$list_tables = mysql_list_tables("vos");
$i=0;
while ($i<mysql_num_rows($list_tables))
{
$tb_names[$i] = mysql_tablename($list_tables,$i);
$msg.=recbase($tb_names[$i]);
$i++;
}
// Compte rendu
header("Location: index.php?msg=$msg&entete=$entete&flag=1");
exit;
?> |
Partager