Condition that checks the register

0

I have to create a condition to check the insertion of a record. In this insert I have dois inputs type radio , one with value="Ok" and one with value="Não Ok" :

$tabela1 .= '<td style="float:center"> <input type="radio" name= "Sim['.$y.']" value="Ok" required></td>';
$tabela1 .= '<td style="float:center"> <input type="radio" name= "Sim['.$y.']" value="Não Ok" required></td>';

When I insert the record into the database table, it inserts 23 rows. When inserting the 23 lines I want to create a if that verifies, if it exists in one of the lines when inserting with value="Não Ok" then the condition is true , if in the 23 lines receive value="Ok" then the condition is false .

I'm doing it this way but it's not working:

if($sim != "Ok"){
....
}else{
....
}

In this way, receive on all 23 lines value="Ok" or on one or more lines receive value="Não Ok" the condition is always false .

    
asked by anonymous 07.12.2018 / 15:22

1 answer

1

First of all, in its% w / o% w / o% w / w is with a capital S, and in php it is small, I do not know if there is a problem, but it's good to leave both equal.

$tabela1 .= '<td style="float:center"> <input type="radio" name= "sim['.$y.']" value="Ok" required></td>';

In PHP, check if any of the inputs are marked "Not OK", if you are setting a variable just to check it, and then check over that variable.

$res = false;
if($Sim == "Não Ok"){
    $res = true;
}

In the next if:

if($res){
    //Não OK
}else{
    //OK
}
    
07.12.2018 / 15:31