<html><head>
<style type="text/css">
#chosen a{
text-decoration:none;
color:black;
}
#chosen a:hover{ text-decoration:none;
color: red;
}
#chosen a span{ display:none; }
#chosen a:hover span{ display: inline; }
</style>
</head>
<body>Click on one square, then submit, then hover your choice!<br /> <br />
<?php
function display_board( $chosen_square )
{
print '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">';
print "\n"; //newline character in the HTML code for readability
print '<div id="chosen" align="center">';
print "\n";
for($x=0; $x<8; $x++)
{
for($y=0; $y<8; $y++)
{
if( ((8*$x) + $y+1) == $chosen_square )
{
print '<input type="radio" name="board_square" value="';
print ((8*$x) + $y+1) . '">';
print '<a href="#"> ';
print ((8*$x) + $y+1);
print "</a>\n";
//the nested for loops formula creates 64 consecutive values
}
else
{
print '<input type="radio" name="board_square" value="';
print ((8*$x) + $y+1) . '"> ' . ((8*$x) + $y+1) . "\n";
}
}
print "<br />\n";
}
print '</div><input type="submit" value="Press Me" /></form>';
}
$chosen_square = stripslashes( $_POST['board_square'] );
if( !empty( $chosen_square ) && isset( $chosen_square ) )
{
print $chosen_square;
}
display_board( $chosen_square );
?>
</body>
</html>