Bonjour,
Je rencontre un petit souci avec mon imbrication de While qui, je pense, devrait théoriquement fonctionner...
Voilà le code PHP avec lequel je tente de réaliser un tableau, affichant les données issues d'une base SQL Server 2003, en executant une procédure stockée.
J'obtiens alors la première ligne du tableau, qui boucle infiniment...
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 <? [...] $date1 = $jour1.'/'.$mois1.'/'.$an1; $date2 = $jour2.'/'.$mois2.'/'.$an2; // execution de la requete sur la base (procedure stockee) $sql2 = "execute dbo.etatComptProd_dicut '".$date1."', '".$date2."';"; $result = mssql_query($sql2, $cnx); // Haut du tableau $titre = '<tr><td colspan = "4" id = "titretab"> Suivi du tonnage Dicut par mode de transport pour la période du '.$date1.' au '.$date2.'</td>'; $nb_lignes = mssql_num_rows($result); $entete_tableau = "<tr id = 'reftab'> <td width=30%><br /></td> <td width=30%><br /></td> <td width=20%><br />Poids brut</td> <td width=20%><br />Cpt</td></tr>"; echo "<table border = '0' id = 'chiffres'>"; echo $titre; echo $entete_tableau; while($row= mssql_fetch_object($result)) { $mois = $row-> libmois; while($mois == $row-> libmois){ echo "<tr id = 'grostitre'><td>Mois : $mois</td>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td></tr>"; $totalPdsBrutMois = 0; $modetransp = $row-> libelléTRS; while($modetransp == $row-> libelléTRS){ echo "<tr><td id = 'bilan'>$modetransp</td>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td></tr>"; $totalPdsBrutTransp = 0; $date = $row-> DATEEXP; while ($date == $row-> DATEEXP){ echo "<tr><td>$date</td>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td></tr>"; $totalPdsBrutJour = 0; $totalCptJour = 0; $numVEH = $row-> NUMVEH; while($numVEH == $row-> NUMVEH){ $poidsBrut = $row-> SommeDePOIDSBRUT; $cpt = $row-> cpt; echo "<tr><td></td>"; echo "<td>$numVEH</td>"; echo "<td>$poidsBrut</td>"; echo "<td>$cpt</td></tr>"; $totalPdsBrutJour += $poidsBrut; $totalCptJour += $cpt; } echo "<tr><td id = 'bilan'>Total jour</td>"; echo "<td></td>"; echo "<td id = 'bilan'>$totalPdsBrutJour</td>"; echo "<td id = 'bilan'>$totalCptJour</td></tr>"; $totalPdsBrutTransp += $totalPdsBrutJour; } echo "<tr><td id = 'bilan'>Total transport</td>"; echo "<td></td>"; echo "<td id = 'bilan'>$totalPdsBrutTransp</td>"; echo "<td></td></tr>"; $totalPdsBrutMois += $totalPdsBrutTransp; } echo "<tr><td id = 'bilan'>Total mois</td>"; echo "<td></td>"; echo "<td id = 'bilan'>$totalPdsBrutMois</td>"; echo "<td></td></tr>"; } } echo '</table>'; // fermer la connexion à sql server mssql_close($cnx); ?> </div> </center>
Mes "While" ne semblent donc pas boucler correctement, serait-ce l'équivalent du "movenext()" en ASP qu'il manquerait à mon code ?...
Merci par avance pour votre aide,
Alex
Partager