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
| <?php
include '../datacamp/conf/conf_bd_pdo.php';
$date1 = "20140401";
$date2 = "20140430";
$sql_1 = $connexion->query(<<<sql
SELECT *
FROM datacamp_emplacement
WHERE
'{$date1}' <= date_fin_emp
AND '{$date2}' >= date_deb_emp
ORDER BY emplacement
sql
);
// par défaut tous les emplacements sont vides
$data = array_fill(1, 110, 'red');
while ($row = $sql_1->fetch(PDO::FETCH_ASSOC))
{
$data[$row['emplacement']] = 'orange';
}
echo <<<'html'
<table border=1 style="font-size:10pt;font-family:verdana,arial,tahoma">
<tr>
html;
foreach($data as $k => $color)
{
echo <<<html
<td width="30" bgcolor="{$color}">{$k}</td>
html;
if (($k !== 110) && (($k % 22) === 0)) // nouvelle ligne tous les 22 emplacements
{
echo <<<'html'
</tr>
<tr>
html;
}
}
echo <<<'html'
</tr>
</table>
html; |