Bonjour alors voila, je voudrais faire un formulaire ou l'utilisateur selectionne un date de debut et une date de fin. Ceci dans un historique je fais donc ca :
J'ai bien mes listes deroulantes et dans ma bdd j'ai une date qui est le 2011-02-03Code:
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 <h2> Recherche par date : </h2> <form action="recherche.php" method="POST"> Du : <SELECT name='i' Size='1'> <?php for($i=1; $i<=31;$i++) { //Lister les jours if ($i < 10) { //Lister les jours pour pouvoir leur ajouter un 0 devant echo "<OPTION>0$i<br></OPTION>"; } else { echo "<OPTION>$i<br></OPTION>"; } } ?> </SELECT> <SELECT name="d" Size="1"> <?php for($d=1; $d<=12;$d++) { //Lister les mois if ($d < 10) { //Lister les jours pour pouvoir leur ajouter un 0 devant echo "<OPTION>0$d<br></OPTION>"; } else { echo "<OPTION>$d<br></OPTION>"; } } ?> </SELECT> <?php $date = date('Y'); //On prend l'année en cours echo '<SELECT name="y" Size="1">'; for ($y=$date; $y<=$date+10; $y++) { //De l'année 2000 à l'année actuelle echo "<OPTION><br>$y<br></OPTION>"; } echo "</SELECT>"; ?> Au <SELECT name='i2' Size='1'> <?php for($i=1; $i<=31;$i++) { //Lister les jours if ($i < 10) { //Lister les jours pour pouvoir leur ajouter un 0 devant echo "<OPTION>0$i<br></OPTION>"; } else { echo "<OPTION>$i<br></OPTION>"; } } ?> </SELECT> <SELECT name="d2" Size="1"> <?php for($d=1; $d<=12;$d++) { //Lister les mois if ($d < 10) { //Lister les jours pour pouvoir leur ajouter un 0 devant echo "<OPTION>0$d<br></OPTION>"; } else { echo "<OPTION>$d<br></OPTION>"; } } ?> </SELECT> <?php $date2 = date('Y'); //On prend l'année en cours echo '<SELECT name="y2" Size="1">'; for ($y2=$date2; $y2<=$date2+10; $y2++) { //De l'année 2000 à l'année actuelle echo "<OPTION><br>$y2<br></OPTION>"; } echo "</SELECT>"; ?> <input type="submit" value="Rechercher"><br/> </form> <a href="index.php"> Retour </a></center> </body> </html>
je test alors ma recherche pour afficher cet evenement voici le code suivant :
mais rien ne s'affiche, je tente alors un echo $debut et un echo $fin et ils s'affichent correctement. que faire...?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
77
78
79
80 <html> <head> <title> Remises </title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body style="background-color:lightblue"> <center> <?php if (isset ($_POST['d'])) { $d=$_POST['d']; } else { $d=""; } if (isset ($_POST['i'])) { $i=$_POST['i']; } else { $i=""; } if (isset ($_POST['y'])) { $y=$_POST['y']; } else { $y=""; } if (isset ($_POST['d2'])) { $d2=$_POST['d2']; } else { $d2=""; } if (isset ($_POST['i2'])) { $i2=$_POST['i2']; } else { $i2=""; } if (isset ($_POST['y2'])) { $y2=$_POST['y2']; } else { $y2=""; } $debut= $y."-".$d."-".$i; $fin= $y2."-".$d2."-".$i2; $debut=date($debut); $fin=date($fin); echo $debut; echo $fin; $link = mysql_connect ('localhost', 'root', ''); mysql_select_db('anomalies', $link); $sql = 'SELECT id, ean, design, rayon, pvc, tel, brii, tract, valide FROM anomalies WHERE ojd BETWEEN \'$debut\' AND \'$fin\' ORDER BY id DESC;'; $req = mysql_query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error()); ?> </body> </html>
Petit details en plus, j'ai modifié un peu mon script et maintenant ca s'affiche :), enfin ca affiche tout sauf ce que je veux ^^