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
|
<table bgcolor="#BABABA" bordercolor="#FFFFFF" border="1" style="font-size:12px" align="center">
<tr>
<th align="center">Titre1</th>
<th align="center">Titre2</th>
<th align="center">Titre3</th>
</tr>
<?php
mysql_connect('', 'root', '');
$sql1=mysql_query("select XXX AS organe, count(YYY) AS NBR_ALARME from TA_TABLE where condition group by XXX");
while($row=mysql_fetch_array($sql1))
{
$total_alarmes+=$row['NBR_ALARME'];
}
$sql=mysql_query("select XXX AS organe, count(YYY) AS NBR_ALARME from TA_TABLE where condition group by XXX");
if (mysql_num_rows($sql1)>0) {
/* ici tu auras besoin de connaitre la somme de toutes les NBR_ALARME, la totalité je veux dire qu'on nommera $total_alarmes
donc il est préférable que tu calcules d'abord la somme de tes count(*) antérieurement dans une autre boucle
*/
echo'<tr>';
echo '<td '.$td1.' align="center" rowspan="'.($total_alarmes+mysql_num_rows($sql1)).'">Alarme</td>';
// une retouche au niveau du rowspan total
$compteur=1;
while($row=mysql_fetch_array($sql))
{
if ($compteur=='1'){
echo '<td '.$td.' align="center" rowspan="'.$row['NBR_ALARME'].'"><font color="red">'.$row['NBR_ALARME'].'</font></td>';
echo '<td '.$td.' align="center" rowspan="'.($row['NBR_ALARME']-1).'">'.$row['organe'].'</td>';
echo '</tr>';
for ($i=1;$i<$row['NBR_ALARME'];$i++){
echo '<tr>';
echo '<td '.$td.' align="center">'.$row['organe'].'</td>';
echo'</tr>';
}
}else{
echo '<tr>';
echo '<td '.$td.' align="center" rowspan="'.($row['NBR_ALARME']+1).'"><font color="red">'.$row['NBR_ALARME'].'</font></td>';
//echo '<td '.$td.' align="center" rowspan="'.($row['NBR_ALARME']-1).'"><font color="blue">'.$row['organe'].'</font></td>';
// ici également une autre retouche car cette ligne ci haut est en plus
echo'</tr>';
for ($i=1;$i<=$row['NBR_ALARME'];$i++){
echo '<tr>';
echo '<td '.$td.' align="center">'.$row['organe'].'</td>';
echo'</tr>';
}
}
$compteur++ ;
}
}
?>
</table> |
Partager