voici mon code je veux exporter une requete en excel lors du click sur le bouton export j'ai ce message
Warning: Cannot modify header information - headers already sent by (output started at D:\test generator eco\test\htdocs\eco\interrogation.php:4) in D:\test generator eco\test\htdocs\eco\interrogation.php on line 86
Warning: Cannot modify header information - headers already sent by (output started at D:\test generator eco\test\htdocs\eco\interrogation.php:4) in D:\test generator eco\test\htdocs\eco\interrogation.php on line 87
Warning: Cannot modify header information - headers already sent by (output started at D:\test generator eco\test\htdocs\eco\interrogation.php:4) in D:\test generator eco\test\htdocs\eco\interrogation.php on line 88
on m'a dit que je ne devez pas utiliser les balises HTML, comment contourner le probléme
existe t'il une autre solution ( code java script ou je ne sais quoi pour contoruner les headers)
Merci
Code : Tout sélectionner
<html>
<!-- CSS pour contourner le bug du textarea sous mozilla -->
<style type="text/css">
textarea#contenu {
height: 20px;
width:10%;
}
</style>
<!-- PHP_SELF lors de la validation rememorise les variables -->
<form name="unform" action="<?$_SERVER['PHP_SELF'];?>" method="post">
tables : <BR>
<SELECT NAME="tables" MULTIPLE SIZE="8" onchange="document.unform.submit();">
<?php
$nom1 = $_GET['schemaInput'];
$Schema=$nom1;
/* Connection postgres */
$conn = pg_pconnect("host=localhost port=5432 dbname=base user=postgres password=postgres");
if (!$conn) {
echo "Une erreur s'est produite.\n";
exit;
}
/* AFFICHE LES TABLES DU SCHEMA et les mets dans une liste */
$requete_tables_du_schema ="select distinct(relname) from pg_attribute, pg_class, pg_namespace where
attnum>0 and attrelid=pg_class.oid and relnamespace=pg_namespace.oid and nspname="."'".$Schema."'";
$resultat = pg_query($conn,$requete_tables_du_schema);
$tableau = array();
while($ligne = pg_fetch_assoc ($resultat))
{
$tableau[] = $ligne; /* memorisation des tables du schema dans un tableau */
}
?>
tables : <BR>
<?php
/* lit le tableau et affiche les schemas */
foreach ($tableau as $tab1)
{
$sel=isset($_POST['tables'])&&($tab1[relname]==$_POST['tables'])?'selected="selected"':' ';
echo "<OPTION VALUE=".$tab1["relname"]." ".$sel." >".$tab1["relname"]."</option>";
}
?>
</SELECT>
<?php
/* MEMORISE Le click de la selection de la table */
if(isset($_POST["tables"])){
$tavariable=$_POST["tables"];
}
?>
<?php
/* affiche le resultat dans un tableau */
include('cmb_champs_table.php');
?>
<INPUT TYPE="submit" NAME="Export" VALUE="Export">
</FORM>
<?php
[b]if(isset($_POST['Export']))
{
$values = pg_query("SELECT * FROM w_exemple.test limit 100 ");
while ($rowr = pg_fetch_row($values)) {
for ($j=0;$j<100;$j++) {
$csv_output .= $rowr[$j]."; ";
}
$csv_output .= "\n";
}
$filename = $file."_".date("Y-m-d_H-i",time());
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("Y-m-d") . ".csv");
header( "Content-disposition: filename=".$filename.".csv");
print $csv_output;
exit;
}
?>[/b]
</html>