views:

66

answers:

1

Hi, I'm an engineering student and I'm developing a simple software based on HTML, PHP and mysql. I learned this topics on w3schools. I know only the basics. I tried to search about this in this website but I found questions about PHP, MySQL and HTML radio buttons which were much more complex than I need and that I could understand. Sorry for the English.

(Q1) Ex: $email=$_REQUEST['email'] , in this case the input is text, if it were like a radio button for ex: sex: male or female, how would it be?

(Q2) what would be the type of this field (for example sex in question 1) in the database: text, int, varchar ?

Thanks for the attention

+5  A: 

Given the html:

<input type="radio" name="sex" value="M" />
<input type="radio" name="sex" value="F" />

In PHP you would get the value from $_REQUEST['sex'], which would give you either M or F, depending on which radio was checked.

A database column to go with this would have the type varchar(1)

You could, of course, use integers as well, just be careful when choosing which value the females get (they tend to prefer the higher one).

Lauri Lehtinen
Great comment on the value of females.
cake