0
I have to create a condition to verify the entry of a record.
In that insertion I have dois inputs type radio
, one with value="Ok"
and another 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 enter the record in the database table, it inserts 23 lines. By inserting the 23 lines I want to create a if
check if it exists in one of the rows when inserting with value="Não Ok"
then the condition is true
, if on the 23 lines you receive the value="Ok"
then the condition is false
.
I’m doing it this way but it’s not working:
if($sim != "Ok"){
....
}else{
....
}
This way, receive in all 23 lines value="Ok"
or in one or more lines receive the value="Não Ok"
the condition is always false
.
so much put
if(in_array("OK", $sim)){
orif(in_array("Não OK", $sim)){
always sends what is inside theelse
– Bruno
Utilize being case sensitive, I just realized that no value this
Ok
and if thisOK
, I’ll edit the question.– Gabriel Queiroz Schicora
I am making the if condition after closing the
for
to send everything only in one email, because if it is inside thefor
sends an email by line. That’s why you can’t check thearray
– Bruno
Dude, without seeing the full code gets kind of hard, but your array
$sim
is receiving in HTML a variable (I imagine it to be counter) inside the brackets, so you need to check the structure of your array, because if the variable$i
is printing1
for example, in if you would usein_array("Ok", $sim[1])
– Gabriel Queiroz Schicora
we can continue to chat?
– Bruno
We can, but instead I suggest you edit your question with the full code and value of the array (use a
var_dump($sim)
) so other people can help too.– Gabriel Queiroz Schicora
I posted but then I deleted it because it gets too much code the question and is not well received by the community
– Bruno
when I do
var_dump($sim)
outside thefor
return thisstring(2) "Ok"
and not the value of the 23 lines, but if done within thefor
already returns the 23 lines, the problem is doing theif
outside thefor
– Bruno
Let’s go continue this discussion in chat.
– Bruno