0
Dear colleagues.
I’m bringing two questions from the Mysql database as follows:
....
Qual sua idade? <input type="text" name="Perguntas[]" value="<?php echo $jmPerguntas->Perguntas; ?>">
Você tem o segundo grau? <input type="text" name="Perguntas[]" value="<?php echo $jmPerguntas->Perguntas; ?>">
Especifique:
<textarea name="Especifique[]" style="width: 200px; height: 80px"></textarea>
.....
And I get the results with PHP this way:
for($i = 0; $i < count($_POST['Perguntas']); $i++){
if($_POST['Perguntas'][$i] == 'Você tem o segundo grau?'){
echo "aqui";
}else{
echo "não aqui";
}
} // fim do for()
The only problem is that the stretch:
if($_POST['Perguntas'][$i] == 'Você tem o segundo grau?'){
echo "aqui";
}else{
echo "não aqui";
}
Is giving "not here", even though the question is 'You have high school?'.
Would anyone know what I’m doing wrong?
Thank you!
What would be a value for
$jmPerguntas->Perguntas
? yes or no?– rray
1) Give a
var_dump
orprint_r
in $_POST. 2) This is some kind of form validation check?– Papa Charlie
Could also explain why the fields have the same name(
perguntas[]
)?– rray
But in this example of yours, why don’t you put the idea instead of bringing the question itself? For there would facilitate in your comparison above... if($_POST['Questions'][$i]='1'){ echo "here"; }.. But I exemplified otherwise, maybe, with the example you can adapt and get where you want.
– Sr. André Baill