Hello,
I am building a survey, in which participants use a html form to enter details.
For example:
What gender are you? Male | Female
The Male/Female option can be selected using a radio button.
However, I would like to store the answer in my database as an INT value, which is 0 for male and 1 for female. How do I write a query which represents that?
I have a rough idea which looks like this, but doesn't seem to work:
$__g = Array('male' => '0', 'female' => '1');
And also, how do I insert the value into the database? I have this, but am unsure if it works (since I can't get the representing part correct)
$sql = "INSERT INTO `onlinesurvey`
(gender) VALUES ('".$__g[$_POST['gender']]."');
Many thanks for your help =)