mysql phpmyadmin,如何保存通过输入类型“select”(下拉)的表单获得的出生日期
我有一个表格询问用户的出生日期。由于我使用选择输入类型,因此它是一个下拉框。第一个下拉菜单有“月”,第二个下拉菜单有“天”,第三个下拉菜单有“年”。因此格式应为月(10 月)、日(25)、年(1990)。换句话说,月份说明了实际的月份,而不仅仅是月份的数字表示。但是,我想以各自的格式保存日期和年份。我如何在 phpMyAdmin 中执行此操作?我应该使用 DATE 类型吗?该值应该是多少?我只需要知道如何在 phpmyadmin 中关联所有这些,这样我就可以正确保存它。谢谢。
I have a form which asks the user his or her date of birth. Its a drop down box since I use the select input type. The first drop down has Months, second has Days, the third has the Years. So the format should be Month(October), Day(25), Year(1990). In other words the months spell out the actual month and not simply the number representation of the month. However, I would like to save the Day and Year in their respective formats. How can I do this in phpMyAdmin? Should I use the DATE type? what should the value be? I just need to know how to correlate all of this in phpmyadmin, so I can save it properly. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是,以下是如何连接它们并将其存储在数据库中:
现在,您可以在查询中针对
date
使用$date
变量类型字段。Yes and here is how you can concatenate them and store in the database:
Now you can use the
$date
variable in your query against thedate
type field.我希望不是 phpmyAdmin 而是 mysql。
那么,您必须区分事物的价值和它的表示。
虽然值可以始终相同,但表示形式可能会有所不同。
在MySQL中存储日期的唯一方法是将其存储在日期字段中,该字段具有严格的格式:
并且您只能以这种格式存储日期。
为此,您必须像这样选择月份:
因此,月份将用单词表示,而数值将发送到服务器。
现在,您可以与日期和年份变量一起组合一个日期字符串:
现在您已准备好将日期存储在数据库中。
Not phpmyAdmin but mysql you mean I hope.
Well, you have to distinguish the value of the thing and it's representation.
While value can be always the same, representation may vary.
The only way to store date in MySQL is to store it in the date field, which has strict format:
And you have to store your date in this format only.
To do this, you have to make your month select like this:
So, month will be represented with word, while numeric value will be sent to the server.
Now, along with day and year variables, you can assemble a date string:
Now you have your date ready to store in the database.