Our task is to create an 8x8 chess board wherein you have to put 8 queens in the board in which the queens won't be able to eat each other. My problem in this code is that the queen images (qb.png & qw.png) are not appearing in the output. Can someone point out what's wrong? Thank you very much.
<HTML>
<head>
<title>Queen's Puzzle</title>
</head>
<style type = "text/css">
table{
border-collapse: collapse;
width: 800px;
border: 1px solid;
}
td{
height: 100px;
width: 100px;
}
.white{
background-color: #FFFFFF;
}
.black{
background-color: #000000;
}
.qw{
width: 95px;
height: 95px;
}
</style>
<body>
<?php
$pos = array(2, 7, 3, 6, 0, 5, 1, 4);
$a = false;
echo '<table>';
for ($row = 0; $row < 8; $row++){
echo '<tr>';
for ($col = 0; $col < 8; $col++){
if ($pos[$row] == $col){
if($a){
echo '<td img class="qw" src="qb.png"></td>';
$a = false;
} else {
echo '<td img class="qb" src="qw.png"></td>';
$a = true;
}
} else {
if($a){
echo '<td class="black"></td>';
$a = false;
} else{
echo '<td></td>';
$a = true;
}
}
}
echo '</tr>';
$a = !($a);
}
echo '</table>';
?>
</body>
</html>
this:
echo '<td img class="qw" src="qb.png"></td>';
Should be:
echo '<td><img class="qw" src="qb.png"></td>';
?