voici mon code
Code php : 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<?php 
 
 require_once "include/connexion.php";
  require_once "include/calcul_hs.php";
$po=$_POST['matricule'];
  $po1=$_POST['datedeb1'];
  $po2=$_POST['datedeb2'];
 
 
  $date = date_create($po2);
date_add($date, date_interval_create_from_date_string('1 days'));
$p=date_format($date, 'Y-m-d');
 
if (empty($po) && empty($po1) && empty($po2) ) {
  echo '<p><h1>veuillez remplir les champs.</h1></p>';
   include('form_recherche.php'); 
   exit;
}
else{
 
if(strtotime($po1) <= strtotime($po2)) {
 
  $cond='';
 if (!empty($po)) {
 
  $cond = " AND h.matricule='$po'";
 //echo "Resultat de recherche du $po1 au $po2";
 $sql= "SELECT * FROM heuresup h,personne p 
WHERE h.matricule=p.matricule 

AND h.datedebut BETWEEN '$po1' AND '$p' $cond ";
 
$res1=mysql_query($sql);
echo '<a href="form_recherche.php">Recherche</a>';
 
 echo'<table border cellspacing="0" cellpadding="6">';
  echo' <thead>';
    echo '<th>Nom </th>';
     echo'  <th>Date debut </th>';
     echo' <th>Date fin </th>';
      echo'<th>Heure debut</th>';
      echo'<th>Heure fin</th>';
      echo'<th>Jour à 50%</th>';
      echo'  <th>Jour à 75%</th>';
       echo' <th>Jour à 150%</th>';
   echo' </thead>';
 
echo'<tbody>';
 
  $Total50 = 0;
  $Total75 = 0;
  $Total150 = 0;
  if(mysql_num_rows($res1)){
 
while($sa = mysql_fetch_array($res1)) {
 
  ?>
 <tr>
 
 
        <td><?php  echo $sa['nom'];?></td>
 
<td><?php   echo date("d-m-20y",strtotime($sa['datedebut']));?></td>
<td><?php  echo date("d-m-20y",strtotime($sa['datefin']));?></td>
<td><?php  /*echo $sa['datedebut'];*/echo date('H:i',strtotime($sa['datedebut']));
        ?></td>
        <td><?php /* echo $sa['datefin'];*/echo date('H:i',strtotime($sa['datefin']));?></td>
<?php 
       $date1 =date_create($sa['datedebut']);
         $date2 = date_create($sa['datefin']);
         $HS=$calculer_HS($date1,$date2);
 
$Total50 += $HS['Type50'];
$Total75 += $HS['Type75'];
$Total150 += $HS['Type150'];
 
 
 
 ?> 
 <td>
   <?php
 
    $s4=$HS['Type50']*3600;
$hours = floor($s4/ 3600);
$minutes = floor(($s4 / 60) % 60);
$seconds = $s4 % 60;
if($hours>=1){
printf("%02dH%02d", $hours, $minutes);
}
 
   ?>
 </td>
            <td>
<?php 
$s5= $HS['Type75']*3600;
$hours = floor($s5/ 3600);
$minutes = floor(($s5 / 60) % 60);
$seconds = $s5% 60;
if($hours>=1){
printf("%02dH%02d", $hours, $minutes);
}
 
 
?>
        </td>
                 <td>
         <?php 
 
         $s6=$HS['Type150']*3600;
$hours = floor($s6/ 3600);
$minutes = floor(($s6 / 60) % 60);
$seconds = $s6% 60;
if($hours>=1){
printf("%02dH%02d", $hours, $minutes);
}
 
 
 
         ?>
        </td>
 
      </tr>
 
<?php
 
 }
}
else{
echo '<p><h1>Resultat vide.</h1></p>';
 
   exit;
}
 
echo'</tbody>';
 
}
 else{
 
 $sql= "SELECT * FROM heuresup h,personne p 
WHERE h.matricule=p.matricule 

AND h.datedebut BETWEEN '$po1' AND '$p' ";
$res2=mysql_query($sql);
echo '<a href="form_recherche.php">Recherche</a>';
 
 echo'<table border cellspacing="0" cellpadding="6">';
  echo' <thead>';
    echo '<th>Nom </th>';
     echo'  <th>Date debut </th>';
     echo' <th>Date fin </th>';
      echo'<th>Heure debut</th>';
      echo'<th>Heure fin</th>';
      echo'<th>Jour à 50%</th>';
      echo'  <th>Jour à 75%</th>';
       echo' <th>Jour à 150%</th>';
   echo' </thead>';
 
 //affichage de requete 1
 
    echo'<tbody>';
 
  $Total50 = 0;
  $Total75 = 0;
  $Total150 = 0;
if(mysql_num_rows($res2)){
 
while($sa = mysql_fetch_array($res2)) {
 
  ?>
 <tr>
 
        <td><?php  echo $sa['nom'];?></td>
 
<td><?php   echo date("d-m-20y",strtotime($sa['datedebut']));?></td>
<td><?php  echo date("d-m-20y",strtotime($sa['datefin']));?></td>
<td><?php  /*echo $sa['datedebut'];*/echo date('H:i',strtotime($sa['datedebut']));
        ?></td>
        <td><?php /* echo $sa['datefin'];*/echo date('H:i',strtotime($sa['datefin']));?></td>
<?php 
       $date1 =date_create($sa['datedebut']);
         $date2 = date_create($sa['datefin']);
         $HS=$calculer_HS($date1,$date2);
 
$Total50 += $HS['Type50'];
$Total75 += $HS['Type75'];
$Total150 += $HS['Type150'];
 
 ?> 
 <td>
   <?php
 
    $s4=$HS['Type50']*3600;
$hours = floor($s4/ 3600);
$minutes = floor(($s4 / 60) % 60);
$seconds = $s4 % 60;
if($hours>=1){
printf("%02dH%02d", $hours, $minutes);
}
 
   ?>
 </td>
            <td>
<?php 
$s5= $HS['Type75']*3600;
$hours = floor($s5/ 3600);
$minutes = floor(($s5 / 60) % 60);
$seconds = $s5% 60;
if($hours>=1){
printf("%02dH%02d", $hours, $minutes);
}
 
 
?>
        </td>
                 <td>
         <?php 
 
         $s6=$HS['Type150']*3600;
$hours = floor($s6/ 3600);
$minutes = floor(($s6 / 60) % 60);
$seconds = $s6% 60;
if($hours>=1){
printf("%02dH%02d", $hours, $minutes);
}
 
 
 
         ?>
        </td>
 
      </tr>
<?php }}
else{
echo '<p><h1>Resultat vide.</h1></p>';
  // include('form_recherche.php'); 
   exit;
}
 
echo'<tbody>';
}}
else{
  echo '<p><h1>veuillez saisir date correcte les champs.</h1></p>';
   include('form_recherche.php'); 
   exit;
}
//affichage de requete 2 
}
 
?>
je voulais afficher des couleur différent dans les lignes en php.A conditions des variable .par exemple je peut mettre les couleur de lignes rouge si on trouves des heure type 50 dans les ligne.don comment je résoudre cette problème.