Ok, I have a problem in my PHP page on a survey, this is the code:
Code: Select all
<?
if ($encuesta == "si"){
require ("cnx.php");
$busqueda= @mysql_query("select * from encuesta_mejormc order by opcion");
while ($row = mysql_fetch_array($busqueda))
{
echo ("<label><input type="."radio"." name="."GrupoOpciones1"." value=".$row["opcion"].">".$row["opcion"]."</label>(".$row["votos"].")<br>");
}
}
else {
if ($vota){
require ("cnx.php");
$id = $idopcion;
echo ($id.$GrupoOpciones1);
$encuesta = "si";
$sql = "update encuesta_mejormc set votos = votos + 1 where idopcion =".$id;
if (!mysql_query($sql)) {
echo "Error en la votacion<br>"; }
$busqueda= @mysql_query("select * from encuesta_mejormc order by opcion");
while ($row = mysql_fetch_array($busqueda))
{
echo ("<label><input type="."radio"." name="."GrupoOpciones1"." value=".$row["opcion"].">".$row["opcion"]."</label>(".$row["votos"].")<br>");
}
}
else {
?><form action="<?=$PHP_SELF?>" method="post"><?
require ("cnx.php");
$busqueda= @mysql_query("select * from encuesta_mejormc order by opcion");
while ($row = mysql_fetch_array($busqueda))
{
echo ("<label><input type="hidden" name="idopcion" value=".$row["idopcion"].">
<input type="radio" name="GrupoOpciones1" value=".$row["opcion"].">".$row["opcion"]."</label><br>");
}
echo ("<br><center><input type="submit" name="vota" value="enviar"></center>");
}
}
?></form><?
?>If i have 3 options like this:
· Option A (ID=3)
· Option B (ID=1)
· Option C (ID=2)
The form always send the ID 2, no matter what option I choose.
I hope that anyone can help me.
Thanks to all.