I noticed that Message-ID: <bo**********@news-reader1.wanadoo.fr> from
Michel contained the following:
An other thing: How to erase the content of a square (after a piece has left
this square) ?
with your example, I tried this:
$img[i][j]="" but then I get an x in the square (image not known)
It all depends on how you are storing the information about the moves.
In my example, I assumed that the information in the database would be
parsed in such a way as to returning all the information on where the
pieces were e.g,
$img=array();
$img[1][1]="rook_black.jpg";
$img[1][3]="rook_white.jpg";
$img[1][6]="king_white.jpg";
//etc, etc.
(It's possibly confusing to call this variable $img because it's really
a position corresponding to a square on the board.)
Then each square calls the function
<td width="50" height="50">
<?php echo display($img[1][1]); ?></td>
<td width="50" height="50">
<?php echo display($img[1][2]);?></td>
<td width="50" height="50">
<?php echo display($img[1][3]);?></td>
//etc. etc.
The function checks if the array position is set
function display($image){
if(isset($image)){
//if it is set, we display the chesspiece image
$showpiece="<img src=\"$image\" alt=\"\">";}
else{
//if it isn't set, we display the word 'empty'
$showpiece="empty";}
return $showpiece;
}
end of function.
If you just want blank square simply change this to
$showpiece="";
see
www.ckdog.co.uk/php/test/chess.php (with more suitable images of
course)
To do any more on this I'll have to know how you are storing the moves
in the database.
--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs
http://www.ckdog.co.uk/rfdmaker/