[SQL] recherche multicritère SQL et checkbox
j'exécute une requete qui m'affiche dans un tableau un libellé et une checkbox
quand l'utilisateur coche la checkbox ça genère une requete SQL avec plusieurs paramètres. Sauf que je n'arrive pas a faire passer les paramètres.
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 76
| <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']))
{
$sql = "SELECT ID FROM ORGANISME;";
if (!$sql) { echo "Erreur requete"; exit;}
$critere = "";
while ($ligne=mysql_fetch_array($sql))
{
$id = $ligne['ID'];
//je sais que la syntaxe est fausse mais c'est le principe
if(isset($_POST[.$id.])
{
$param = $critere."(((ORGANISME_MEMBRE.ID)=".$id.")) OR ";
$critere = $param;
}
}
echo $critere;
$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)=".$critere."));";
}
?>
</head>
<body>
</br>
<form name="form1" method="post" action="">
<table width="270" border="0" cellspacing="0" cellpadding="0" align="center">
<?php
$sql=mysql_query("SELECT ID, LIBELLES FROM ORGANISME GROUP BY LIBELLES;");
if (!$sql) { echo "Erreur requete"; exit;}
while ($ligne=mysql_fetch_array($sql))
{
$lib = $ligne['LIBELLES'];
$id = $ligne['ID'];
?>
<tr>
<td width="200" align="center" height="35"><?php echo $lib;?></td>
<td width="70" align="center" height="35"><input type=checkbox name="<?php echo $id;?>" value="<?php echo $id;?>"</td>
</tr>
<?php
}
?>
</table></br>
<div align="center">
<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> |