Hi there, I have a problem with a vote thing in php
the code of my page is:
$active = '1';
$data = time();
$autor = $_SESSION['username'];
$question = $_POST['question'];
$contador = 2;
$contagem = '0';
while ($contagem <= $resps) {
$contagem++;~
$contador++;
$question = $_POST['question'];
$choice = $contagem;
$teste = "choice$contador";
$choice = $_POST['$teste'];
$activity = $_POST['question'];
$votes = '0';
$q2 = "INSERT INTO poll_answers (choice, activity, votes) VALUES ('$choice', '$activity', '$votes')";
if($database->query($q2)){echo "sucssso answews";}else{echo "falha answrrs";}
$contador++;
}
$q = "INSERT INTO poll_questions (question, active) VALUES ('$activity', '$active')";
if($database->query($q))
{ echo "sucesso questoes";}
else{ echo"falha questoes";}
echo "inserido";
?>
<form action="" name="votacao2" method="post">
<table>
<tr><td><strong>Pergunta</strong></td><td><textarea name="question" cols="50" rows="1"></textarea></td></tr>
<?php
$contador = '2';
$respos = $resps + 2;
while ($contador < $respos) {
$contador++;
echo "<tr><td><strong>Resposta</strong></td><td><textarea name=\"choice$contador\" cols=\"50\" rows=\"1\"></textarea>
</td></tr>
";
}
?>
<tr><td><input type="submit" name="enviar" value="Enviar" /></td></tr>
</table>
</form>
I think the only thing not working is this:
$teste = "choice".$contador;
$choice = $_POST['$teste'];
And I don«t know how to do it, so once again I ask your help.
Thanks in advance :)
I edit this post, so now I hope you understand my problem, I'm tryinmg to do a poll and it isnt working, when I insert the data, the row choice has a 0 in it, I can see it in phpmyadmin.