I'm working on a little poll but when the vote button is clicked it does nothing. The believed cause of this problem is the two select queries that are present in my code. When one is taken out the vote button submits like it's suppose.
Now you'd think problem solved but taking out one of the select queries causes the poll question the be repeated with every poll option that's listed.
Here's the poll with the both select queries:
$sql = ("SELECT store_polls.poll_question, store_poll_options.poll_option_id,
store_poll_options.poll_option_text FROM store_polls, store_poll_options WHERE store_polls.poll_id='1'
AND store_poll_options.poll_id=store_polls.poll_id");
$result = mysql_query($sql);
if (!$result)
echo"<form method=\"post\" action=\"result.php\">";
while ($result = mysql_fetch_array($result))
{
$poll_question = $result['poll_question'];
echo "$poll_question<br>";
}
$sql = ("SELECT store_polls.poll_question, store_poll_options.poll_option_id,
store_poll_options.poll_option_text FROM store_polls, store_poll_options WHERE store_polls.poll_id='1'
AND store_poll_options.poll_id=store_polls.poll_id");
$result = mysql_query($sql);
if (!$result) {
echo 'Query failed: ', mysql_error();
exit;
}
while ($row = mysql_fetch_assoc($result))
{
$option = $row['poll_option_text'];
$poll_id = $row['poll_option_id'];
echo "<input type=\"radio\" name=\"poll\" value=\"$poll_id\">$option<br>";
}
echo"<input type=\"submit\" value=\"vote\">";
echo"</form>";
echo"</table>";
And here it is without:
$sql = ("SELECT store_polls.poll_question, store_poll_options.poll_option_id,
store_poll_options.poll_option_text FROM store_polls, store_poll_options WHERE store_polls.poll_id='1'
AND store_poll_options.poll_id=store_polls.poll_id");
$result = mysql_query($sql);
if (!$result) {
echo 'Query failed: ', mysql_error();
exit;
}
echo"<form method=\"get\" name=\"submit\" action=\"polls.php?cmd=poll_results\">";
while ($row = mysql_fetch_assoc($result))
{
$option = $row['poll_option_text'];
$poll_id = $row['poll_option_id'];
$poll_question = $row['poll_question'];
//the problem! the poll question is repeated with every poll option
echo "$poll_question<br>";
echo "<input type=\"radio\" name=\"poll\" value=\"$poll_id\">$option<br>";
}
echo"<div align=\"center\"><input type=\"submit\" value=\"vote\"></div>";
echo"</form>";
echo"</table>";