<?php
$num_cells = 5; //how many cells show
$loc_x = 0; //taken from DB or input by user
$loc_y = 7; //taken from DB or input by user
$min_x = $loc_x - $num_cells; //minimum number map in x
$max_x = $loc_x + $num_cells; //maximum number map in x
$min_y = $loc_y - $num_cells; //minimum number map in y
$max_y = $loc_y + $num_cells; //maximum number map in y
?>
<table border='1'>
<tr bgcolor='#C0C0C0'>
<td width='25'></td>
<?php
//scale of x
for($x=$min_x; $x<=$max_x; $x++){
echo "<td width='25'><center><b>$x</b></center></td>";
}
?>
</tr>
<?php
for($y=$min_y; $y<=$max_y; $y++){
echo "<tr>";
echo "<td width='25' bgcolor='#C0C0C0'><center><b>$y</b></center></td>"; //scale of y
for($x=$min_x; $x<=$max_x; $x++){
if($x == $loc_x && $y == $loc_y){ //cheking if it's position of user
echo "<td width='25'><center>X</center></td>"; //if yes, so put X
}else{
echo "<td width='25'></td>"; //if no, just free calumn
}
}
echo "</tr>";
}
?>
</table>