problème de variable passée en paramètre de requête suite à export
je fais un export de ma base de données mysql. Je choisis via une sélection un type d'organisme. L'export fonctionne mais j'ai toujours le même message :
"Notice: Use of undefined constant organisme - assumed 'organisme' in C:\Program Files\EasyPHP 2.0b1\www\courrier\export.php on line 11
"
Voila le code
Code:
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 70 71 72 73 74 75
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>EXporter</title>
<?php
include "connec.inc.php";
if(isset($_POST['valider']))
{
$id = $_POST[organisme];
$query = "SELECT MEMBRES.NOM, MEMBRES.PRENOM, MEMBRES.ADRESSE, MEMBRES.CP, MEMBRES.VILLE, ORGANISME_MEMBRE.ID, ORGANISME.LIBELLES "
."FROM ORGANISME INNER JOIN (MEMBRES INNER JOIN ORGANISME_MEMBRE ON MEMBRES.NUMERO = ORGANISME_MEMBRE.NUMERO) ON ORGANISME.ID = ORGANISME_MEMBRE.ID "
."WHERE (((ORGANISME_MEMBRE.ID)=".$id."));";
$result = mysql_query($query) or die('Erreur SQL !<br />' . $query . '<br />' . mysql_error());
$csv_output = "'LIBELLES;'NOM;'PRENOM;'ADRESSE;'CP;'VILLE\n";
while($row = mysql_fetch_array($result))
{
$csv_output .= "$row[LIBELLES];$row[NOM];$row[PRENOM];$row[ADRESSE];$row[CP];$row[VILLE]";
$csv_output .= "\n";
}
$fichier="D:/export.csv";
if (!$handle = fopen($fichier, 'w+')) {
$msg="Impossible d'ouvrir / creer ($fichier)";
exit;
} elseif (fwrite($handle, $csv_output) === FALSE) {
$msg="Impossible d'ecrire dans le fichier ($fichier)";
exit;
} else {
$msg="L'export est terminé dans $fichier";
fclose($handle);
}
}
?>
</head>
<body>
</br>
<form name="form1" method="post" action="">
<div align="center">
<select name="organisme" id="organisme">
<option value='AUCUN'>****Sélectionnez****</option>
<?php
$sql=mysql_query("SELECT ID, LIBELLES FROM ORGANISME GROUP BY LIBELLES;");
if (!$sql) { echo "Erreur requete"; exit;}
while ($ligne=mysql_fetch_array($sql))
{
?>
<option value= '<?php echo ''.$ligne['ID'].'';?>'><?php echo ''.$ligne['LIBELLES'].'';?> </option>
<?php
}
?>
</select>
<input type="submit" name="valider" value="Exporter" style="background-color:#358F27; color:white; font-weight:normal">
</div>
</form>
</br>
<?php
if (isset($msg))
{
echo "<table width='450' border='1' align='center' cellpadding='0' cellspacing='0' bordercolor='#DC6607'>";
echo "<tr>";
echo "<td height='50' valign=middle><p align='center'>$msg</p></td>";
echo "</tr>";
echo "</table>";
}
?>
</body>
</html> |