<?php
$rowsAmt = 9;
$colsAmt = 9;
$boxGroupWidthSize = 3;
$boxGroupHeightSize = 3;
//a box is an indivdual cell
//a box group is a group of boxes
function boxIsInBoxGroup($boxRow, $boxCol) {
$boxIsInBoxGroupRow = $boxRow % $boxGroupHeightSize;
//if the $rowsAmt is 9 and $boxWidthSize is 3, $boxIsInBoxCol ranges
//from 0 to 2, because that means there can be up to 3 distint box groups
//a box groups is a group of boxes (aka cells) (3 by 3 cells for example) defined by
$boxIsInBoxGroupCol = $boxCol % $boxGroupWidthSize;
return array($boxIsInBoxGroupRow, $boxIsInBoxGroupCol);
}
function isStrInBoxGroup($something, $boxGroup) {
//to get boxGroup array us boxIsInBoxGroup func
}
if (checkIfPost()) {
for ($c = 0; $c < $rowsAmt; $c ++;) {
for ($c2 = 0; $c2 < $colsAmt; $c2 ++) {
$dataByRow[$c][$c2] = $_POST['box'.$c.'_'.$c2];
$dataByCol[$c2][$c] = $_POST['box'.$c.'_'.$c2];
}
}
for ($num = 1; $num <= 9; $num ++) {
for ($c = 0; $c < $rowsAmt; $c ++;) {
if (!in_array($num, $dataByRow[$c]) && !in_array($num, $dataByCol)
&& !inBoxGroup($c, 0)) {
//if number c is not in the row and not in the column
}
}
}
echo '<form>
<table>';
for ($c = 0; $c < $rowsAmt; $c ++) {
echo '<tr>';
for ($c2 = 0; $c2 < $colsAmt; $c2 ++) {
echo '<td>';
echo '<input type="text" id="box'.$c.'_'.$c2.'">';
echo '</td>';
}
echo '</tr>';
}
echo '</table>
</form>';
?>