bonjour
désoler de refaire un énième topique al dessus, mais même en cherchant et en regardant des exemples
j'ai pas mal de difficulté a réaliser ce formulaire
donc je cherche a faire un formulaire multicritère ou on choisis une ou plusieurs option ça affiche tout les résultats en fonction de ces options
le problème ben c'est que j'ai pas mal de champs afficher, et du coup ma méthode fonctionne bien uniquement quand on peut de choses afficher, ,en effet je dois effectuer ma recherche avec 7-8 critère et en afficher plus de 10, donc je sais pas trop quoi utiliser pour en arriver là.
si vous avez des idées

code de la recherche :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php require_once('Connections/gali.php');
ini_set('error_reporting', 'E_ALL ^ E_NOTICE'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
 
mysql_select_db($database_gali, $gali);
$query_Recherche = "SELECT * FROM markers";
$Recherche = mysql_query($query_Recherche, $gali) or die(mysql_error());
$row_Recherche = mysql_fetch_assoc($Recherche);
$totalRows_Recherche = mysql_num_rows($Recherche);
?>
<form method="post" action="add.php">
                        <p>
                                nom du site : <br />
                          <select name="name"  id="name "value="Choisissez">
                            <option value="" selected="selected"></option>
                            <?php
do {  
?>
                            <option value="<?php echo $row_Recherche['name']?>"><?php echo $row_Recherche['name']?></option>
                            <?php
} while ($row_Recherche = mysql_fetch_assoc($Recherche));
  $rows = mysql_num_rows($Recherche);
  if($rows > 0) {
      mysql_data_seek($Recherche, 0);
	  $row_Recherche = mysql_fetch_assoc($Recherche);
  }
?>
                          </select>
                          <br />lieu: <br />
                                <select name="address">
                                  <option value="" selected="selected"></option>
                                  <?php
do {  
?>
                                  <option value="<?php echo $row_Recherche['address']?>"><?php echo $row_Recherche['address']?></option>
                                  <?php
} while ($row_Recherche = mysql_fetch_assoc($Recherche));
  $rows = mysql_num_rows($Recherche);
  if($rows > 0) {
      mysql_data_seek($Recherche, 0);
	  $row_Recherche = mysql_fetch_assoc($Recherche);
  }
?></select>
              					<br />statut: <br />
                                <select name="situation">
                                  <option value="" selected="selected"></option>
                                  <?php
do {  
?>
                                  <option value="<?php echo $row_Recherche['situation']?>"><?php echo $row_Recherche['situation']?></option>
                                  <?php
} while ($row_Recherche = mysql_fetch_assoc($Recherche));
  $rows = mysql_num_rows($Recherche);
  if($rows > 0) {
      mysql_data_seek($Recherche, 0);
	  $row_Recherche = mysql_fetch_assoc($Recherche);
  }
?></select>                     
                   				<br />ddetails occupants: <br />
                                <select name="situation2">
                                  <option value="" selected="selected"></option>
                                  <?php
do {  
?>
                                  <option value="<?php echo $row_Recherche['situation2']?>"><?php echo $row_Recherche['situation2']?></option>
                                  <?php
} while ($row_Recherche = mysql_fetch_assoc($Recherche));
  $rows = mysql_num_rows($Recherche);
  if($rows > 0) {
      mysql_data_seek($Recherche, 0);
	  $row_Recherche = mysql_fetch_assoc($Recherche);
  }
?></select>               
                               <br />comportement: <br />
                               <select name="comportement">
                                 <option value="" selected="selected"></option>
                                 <?php
do {  
?>
                                 <option value="<?php echo $row_Recherche['comportement']?>"><?php echo $row_Recherche['comportement']?></option>
                                 <?php
} while ($row_Recherche = mysql_fetch_assoc($Recherche));
  $rows = mysql_num_rows($Recherche);
  if($rows > 0) {
      mysql_data_seek($Recherche, 0);
	  $row_Recherche = mysql_fetch_assoc($Recherche);
  }
?></select>                      <br />satde reproduction: <br />
                               <select name="stad_repro">
                                 <option value="" selected="selected"></option>
                                 <?php
do {  
?>
                                 <option value="<?php echo $row_Recherche['stad_repro']?>"><?php echo $row_Recherche['stad_repro']?></option>
                                 <?php
} while ($row_Recherche = mysql_fetch_assoc($Recherche));
  $rows = mysql_num_rows($Recherche);
  if($rows > 0) {
      mysql_data_seek($Recherche, 0);
	  $row_Recherche = mysql_fetch_assoc($Recherche);
  }
?></select>
 
 
  <input type="submit" value="Valider" /><br /></form>
<?php
mysql_free_result($Recherche);
?>
et m page resultat:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
@session_start();
include "connection.php"; 
 
ini_set('error_reporting', 'E_ALL ^ E_NOTICE');
 
 
$test=0;
$name = $_POST['name'] ;
$address = $_POST['address'] ;
$region = $_POST['region'] ;
$situation = $_POST['situation'] ;
$situation2 = $_POST['situation2'] ;
$nbrfau = $_POST['nrbfau'] ;
$comportement = $_POST['comportement'] ;
$stad_repo = $_POST['stad_repro'] ;
$nbrpouss = $_POST['nbrpouss'] ;
$oeuf_pouss = $_POST['oeuf_pouss'] ;
$observation = $_POST['observation'] ;
$nbrjuv = $_POST['nbrjuv'] ;
 
 
 
 
 
  $query =('SELECT * FROM markers');
  if  ($name!="" || $address!="" || $region!="" || $situation!="" || $situation2!="" || $nbrfau!="" || $comportement!="" || $stad_repro!="" || $nbrpouss!="" || $oeuf_pouss!="" || $observation!="" || $nbrjuv!="") {$query.=" WHERE ";}
 
  if ($name!="") {$query.=" (name  like '%$name%' OR  name like '%$name%' OR name like '%$name%') "; $t=1; }
 
  if ($t==1  && $address!=""){$query.=" AND ";}
  if ($address!="") {$query.=" (address  like '%$address%' OR address like '%$address%' OR address like '%$address%') "; $s=1; }
 
  if ($s==1 && $region !=""){$query.=" AND "; $v=0;}
  if ($v==0 && ($t==1 && $region !="")) {$query.=" AND "; $v=0;}
  if ($region !="") {$query.=" (region   like '%region %' OR region  like '%$region %' OR region  like '%$region %') ";  }
 
  if ($s==1 && $situation !=""){$query.=" AND "; $v=0;}
  if ($v==0 && ($t==1 && $situation !="")) {$query.=" AND "; $v=0;}
  if ($situation!="") {$query.=" (situation  like '%$situation%' OR situation like '%$situation%' OR situation like '%$situation%') "; $s=1; }
 
  if ($s==1 && $situation2 !=""){$query.=" AND "; $v=0;}
  if ($v==0 && ($t==1 && $situation2 !="")) {$query.=" AND "; $v=0;}
  if ($situation2!="") {$query.=" (situation2  like '%$situation2%' OR situation2 like '%$situation2%' OR situation2 like '%$situation2%') "; $s=1; }
 
  if ($s==1 && $nbrfau !=""){$query.=" AND "; $v=0;}
   if ($v==0 && ($t==1 && $nbrfau !="")) {$query.=" AND "; $v=0;}
  if ($nbrfau !="") {$query.=" (nrbfau   like '%nrbfau%' OR nrbfau  like '%$nrbfau%' OR nrbfau  like '%$nrbfau%') "; }
 
  if ($s==1 && $comportement !=""){$query.=" AND "; $v=0;}
  if ($v==0 && ($t==1 && $comportement !="")) {$query.=" AND "; $v=0;}
  if ($comportement!="") {$query.=" (comportement like '%$comportement%' OR comportement like '%$comportement%' OR comportement like '%$comportement%') "; $s=1;}
 
  if ($s==1 && $stad_repro !=""){$query.=" AND "; $v=0;}
  if ($v==0 && ($t==1 && $stad_repro !="")) {$query.=" AND "; $v=0;}
  if ($stad_repro!="") {$query.=" (stad_repro  like '%$stad_repro%' OR stad_repro like '%$stad_repro%' OR stad_repro like '%$stad_repro%') "; $s=1; }
 
  if ($s==1 && $nbrpouss !=""){$query.=" AND "; $v=0;}
  if ($v==0 && ($t==1 && $nbrpouss !="")) {$query.=" AND "; $v=0;}
  if ($nbrpouss !="") {$query.=" (nbrpouss   like '%nbrpouss %' OR nbrpouss  like '%$nbrpouss %' OR nbrpouss like '%$nbrpouss %') "; }
 
 
  if ($s==1 && $oeuf_pouss !=""){$query.=" AND "; $v=0;}
  if ($v==0 && ($t==1 && $oeuf_pouss !="")) {$query.=" AND "; $v=0;}
  if ($oeuf_pouss!="") {$query.=" (oeuf_pouss  like '%$oeuf_pouss%' OR oeuf_pouss '%$oeuf_pouss%' OR oeuf_pouss like '%oeuf_pouss%') "; $t=1; }
 
  if ($s==1 && $observation !=""){$query.=" AND "; $v=0;}
  if ($v==0 && ($t==1 && $stad_repro !="")) {$query.=" AND "; $v=0;}
  if ($observation!="") {$query.=" (observation  like '%$observation%' OR observation like '%$observation%' OR observation like '%$observation%') "; $s=1; }
 
  if ($s==1 && $nbrjuv !=""){$query.=" AND "; $v=0;}
   if ($v==0 && ($t==1 && $nbrjuv !="")) {$query.=" AND "; $v=0;}
  if ($nbrjuv !="") {$query.=" (nbrjuv   like '%nbrjuv %' OR nbrjuv  like '%$nbrjuv %' OR nbrjuv like '%nbrjuv %') "; }
 
 
echo $query;
$query2 = mysql_query($query)or die(mysql_error());
 
?>
<table width="200" border="1">
  <tr>
    <th scope="col">nom site</th>
    <th scope="col">lieu</th>
    <th scope="col">region</th>
  	<th scope="col">statut</th>
    <th scope="col">details occupant</th>
    <th scope="col">nombre faucon</th>
  	<th scope="col">comportement</th>
    <th scope="col">stade reproduction</th>
    <th scope="col">nombre poussin</th>
  	<th scope="col">estimation</th>
    <th scope="col">observation</th>
    <th scope="col">nombre juvenil</th>
 
 
  </tr>
<?php
while ($r = mysql_fetch_assoc ($query2)) {
?>  <tr>
    <td><?php  echo $r['name'];?></td>
    <td><?php  echo $r['address'];?></td>
    <td><?php  echo $r['region'];?></td>
 	<td><?php  echo $r['situation'];?></td>
    <td><?php  echo $r['situation2'];?></td>
    <td><?php  echo $r['nrbfau'];?></td>
 	<td><?php  echo $r['comportement'];?></td>
    <td><?php  echo $r['stad_repro'];?></td>
    <td><?php  echo $r['nbrpouss'];?></td>
 	<td><?php  echo $r['oeuf_pouss'];?></td>
    <td><?php  echo $r['observation'];?></td>
    <td><?php  echo $r['nbrjuv'];?></td>
 
 
 
  </tr>
  <?php }?>
</table>
et une dexieme chose je voudrai faire des recherche par année, dans ma bdd j'ai un champs date au format (yyyy/dd/mm) ,mais je vois pas trop comment effectuer la requête sur ce champs