bonsoir a tous,
j ai un petit soucis, je me perd dans les imbrications...
je voudrais rajouter un order by dans ma requete, mais j ai bcp de mal....
voici le code
par avance merci
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 <? include("connect.php5"); if(isset($action)) { //--------------------- recuperation des enregistrements --------- $tab_champs = array("type","type_bien","nb_piece", "surface"); $query = "select * from bien where"; $i=0; $ajouter_and = false; foreach($rechercher as $champs) { if($champs!="0") { if($ajouter_and) { $query .= " and "; } else { $query .= " "; } $ajouter_and = true; if($i==3){ if($champs!="0") { $condition = ''; switch ($champs) { case 20: $condition = "surface >= '0' AND surface <= '20'"; break; case 50: $condition = "surface > '21' AND surface <= '50'"; break; case 75: $condition = "surface > '51' AND surface <= '75'"; break; case 100: $condition = "surface > '76' AND surface <= '100'"; break; case 150: $condition = "surface > '101' AND surface <= '150'"; break; case 200: $condition = "surface > '151' AND surface <= '200'"; break; case 250: $condition = "surface > '201' AND surface <= '250'"; break; case 300: $condition = "surface > '251' AND surface <= '300'"; break; case 301: $condition = "surface > '300'"; break; } } $query .= $condition; } else { $query .= $tab_champs[$i]."='".$champs."'"; } } $i++; } if($ajouter_and==false) $query .= " 1"; $result = mysql_query($query); $nb_bien = mysql_num_rows($result); } ?>
Bonne soiree
francescu
Partager