I am working on some kind of 6x6 Sudoku table.
In this function, I am trying to check whether player’s input is correct or not. If the input in the textbox is correct, textbox inside a specific cell should become blue lable, a if not, red label. Like this: https://github.com/auroraautonoa/RP2/blob/master/92675921_1547918548692550_3119402637909295104_n.png
My function checks only for the first textbox, txt_0 (they are enumerated by txt_0…txt_35), converts the textbox into blue/red label, but outside the table. I am aware that this echo… line doesn’t work but i tried to change the value of specific txtbox and it’s not working.
function check()
{
for ($count=0; $count < 36; ++$count )
{
$player_input = [];
if( isset( $_POST['txt_'.$count.''] ) )
{
$options = array( 'options' => array( 'min_range' => 1, 'max_range' => 6 ) );
if (filter_var( $_POST['txt_'.$count.''], FILTER_VALIDATE_INT, $options ) === false){
$this->errorMessage = 'Number must be between 1 and 6.';
return false;}
else
$number = (int) $_POST['txt_'.$count.''];
$player_input[] = $number;
if( self::correct_array[$count] === $number)
echo '<label class="correctNumber">'.$number.'</label>';
else
echo '<label class="falseNumber">'.$number.'</label>';
//echo '<input type="text" class="falseNumber" value="'.$number.'" id="txt_'.$count.'" name="txt_'.$count.'"/>';
}
else
return false;
//check if all inputs are correct
foreach ( $player_input as $x )
{
if( self::correct_array[$count] === $x)
return true;
return false;
}
}
}
const correct_array=array(2, 3, 4, 1, 5, 6, 1, 5, 6, 2, 3, 4, 3, 1, 2, 4, 6, 5, 4, 6, 5, 3, 1, 2, 5, 2, 1, 6, 4, 3, 6, 4, 3, 5, 2, 1); this is the whole table defined in my class
Sorry for the long post, but I could really use some help since I’m beginner.