IF dans le resultat d'un tableau
Bonjour,
Je souhaite afficher une image en fonction du resultat d'une requete si le resultat de W19 = 0 image1 sinon image2.
J'ai testé des if dans la boucle sans succes
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
|
<table width="400px">
<tr>
<td>YEAR</td>
<td>19</td>
<td>20</td>
<td>21</td>
</tr>
<?php
$sql= "SELECT yearweek.`Year`
,COUNT(IF(yearweek.Week=19,tbltimecarddata.WeekWC,NULL)) AS W19
,COUNT(IF(yearweek.Week=20,tbltimecarddata.WeekWC,NULL)) AS W20
,COUNT(IF(yearweek.Week=21,tbltimecarddata.WeekWC,NULL)) AS W21
FROM
yearweek
LEFT OUTER JOIN tbltimecarddata
ON yearweek.`Year` = tbltimecarddata.YearWC AND yearweek.Week = tbltimecarddata.WeekWC GROUP BY `Year`";
$resultat=mysql_query($sql);
while($ligne=mysql_fetch_assoc($resultat)){
?>
<tr>
<td><?php echo $ligne['Year']; ?></td>
<td><?php echo $ligne['W19']; ?></td>
<td><?php echo $ligne['W20']; ?></td>
<td><?php echo $ligne['W21']; ?></td>
</tr>
<?php
}
?>
</table> |