-
Notifications
You must be signed in to change notification settings - Fork 0
/
echiquier.php
64 lines (45 loc) · 1.01 KB
/
echiquier.php
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
<!doctype html>
<html lang="fr">
<head>
<title>Echiquier</title>
<style>
table { border-collapse: collapse;}
td { width:50px; height:50px; padding:0}
.clair { background:#FCFAE1;}
.sombre { background:#BD8D46;}
.img { margin:0;padding:0;}
#contenu { width:500px; margin: 0 auto;}
</style>
</head>
<body>
<div id="contenu">
<table>
<?php
$ligmax=8;
$colmax=8;
$pos[5][2]="fou_b.png";
$pos[8][1]="roi_n.png";
for($i=1;$i<=8;$i++){
$pos[7][$i]="pion_n.png";
$pos[2][$i]="pion_b.png";
}
for ($lig=$ligmax; $lig>0; $lig--){
echo "<tr>";
for ($col=1; $col<=$colmax; $col++){
$couleur=(($lig+$col)%2==0)?"clair":"sombre"; //Operateur ternaire
if(isset($pos[$lig][$col])){
$piece=$pos[$lig][$col];
}
else{
$piece='vide.png';
}
$piece=$pos[$lig][$col]??'vide.png';
echo "<td class=\"$couleur\"><img src=\"img/$piece\" alt=\"\"></td>";
}
echo "</tr>";
}
?>
</table>
</div>
</body>
</html>