关于单选按钮/PHP/MySQL 的问题

发布于 2024-09-04 16:47:53 字数 331 浏览 3 评论 0原文

我是一名工科学生,正在开发一个基于 HTML、PHP 和 mysql 的简单软件。我在 w3schools 上学到了这个主题。我只知道基础知识。我试图在这个网站上搜索这个问题,但我发现了有关 PHP、MySQL 和 HTML 单选按钮的问题,这些问题比我需要的复杂得多,而且我可以理解。对不起英语。

(Q1) 例如: $email=$_REQUEST['email'] ,在这种情况下输入是文本,如果它像一个单选按钮,例如:性别:男性或女性,会怎么样是?

(问题 2)数据库中该字段(例如问题 1 中的性别)的类型是什么:text、int、varchar?

感谢您的关注

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

被翻牌 2024-09-11 16:47:53

给定 html:

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

在 PHP 中,您将从 $_REQUEST['sex'] 获取值,这将为您提供 MF,取决于检查的收音机。

与此相关的数据库列的类型为 varchar(1)

当然,您也可以使用整数,只是在选择女性获得的值时要小心(她们往往更喜欢较高的值)一)。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文