I have a 9x9 field. When I press any button, I want it to display the coordinates, but for some reason it doesn't.
Does someone know where it goes wrong? Am I doing something which is impossible?
Current code:
<?php
echo "<iframe name='frame'></iframe>";
$aww_ar = array();
// SELECT PLAYING FIELD ValLUES
$th = 10;
$tw = 10;
// Amount of numbers
$amount = 5;
// Create 2d array
for ($y = 0;$y < $th;$y++) {
for ($x = 0;$x < $tw;$x++) {
$randomise = rand(1, $amount);
$aww_ar[$x][$y] = $randomise;
}
}
// create 2d table array
?>
<form method="post" target="frame" action="">
<table>
<?php
foreach ($aww_ar as $x => & $value) {
echo "<tr>";
foreach ($aww_ar[0] as $y => $v) {
echo "<td><input type='submit' name='" . $x . ',' . $y . "' value='" . $aww_ar[$x][$y] . "'></td>";
}
echo "</tr>";
}
?>
</table>
</form>
<?php
if (isset($_POST[$x . ',' . $y])) {
echo $x . ',' . $y;
}