0
I wanted to insert the table data (Sqlite) into a CSV file. I do a query first, and I want to insert the result of that query into the CSV file. Exists in PHP the function fputcsv
. I can create the file but wanted to insert. Here’s the code:
for ($i=0; $i<=$nombre;$i++){
$requete = "SELECT * FROM contact WHERE $selectoption='$search' AND id=$i";
$resultat = $base_hndl->query($requete);
$affiche = $resultat->fetchArray();//
echo "<tr>";
echo "<td>$affiche[nom]</td>";
echo "<td>$affiche[prenom]</td>";
echo "<td>$affiche[fonction]</td>";
echo "<td>$affiche[societe]</td>";
echo "<td>$affiche[mobile]</td>";
echo "<td>$affiche[mail]</td>";
echo "</tr>";
}
$fp = fopen($search.".csv", 'w');
fputcsv($fp, $list);
fclose($fp);
echo "ficheiro csv criado";
}
http://meta.pt.stackoverflow.com/questions/297/quando-se-deve-colocar-o-nome-da-linguagem-no-t%C3%ADtulo/1911#1911
– Maniero