开发者

Question about Radio button/PHP/MySQL

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 En开发者_运维知识库glish.

(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


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜