I'm creating a poll script with up to 10 available answers. I'm using the below code to check answers and add them into my mySQL database however all the POST "answers" are returning blanks when they shouldn't. Can someone help me out?![]()
PHP Code://This is my current code
for($i=1;$i<11;$i++) {
if ($_POST['answer$i'] != "") {
$answer = $_POST['answer$i'];
$add_answer = mysql_query("INSERT into answers VALUES('$id', '$answer, '0')", $db);
}
PHP Code://If I use this is picks up the POST "answer" value
$answer = $_POST['answer1'];
//but this doesn't
$i="1";
$answer = $_POST['answer$i'];




Reply With Quote