Sunday, 18 August 2013

Inserting multiple checkboxsed into MySQL

Inserting multiple checkboxsed into MySQL

I want to create something like quiz in php and mysql. It's just for fun,
but still, I have a problem with submitting radio inputs. Example of HTML:
<input type="radio" name="news[]"
value="0"><label>Nie</label>&nbsp;&nbsp;
<input type="radio" name="news[]" value="1"><label>Tak</label>
and my SQL is as follows:
$answer1 = $_POST['news'];
$answer2 = $_POST['politics];
mysql_query('INSERT INTO quiz (id, answer1, answer2...) VALUES (null,
$answer1, $answer2...);
It alsways inserts 0, no matter what will I check. I know I cal solve this
by using foreach, but this will - I think - create multiple INSERT
statements.

No comments:

Post a Comment