本文介绍了如何从php表单中收集出生日期并插入到mysql中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是编程新手,做了一些事情,但我不知道如何收集dob信息。我如何从表格中收集它,以及如何插入它?我是否使用三个字段:月/日/年,然后在数据库中也有三列?



有没有我可以指出的教程?



谢谢

解决方案

取决于您要做什么(如果它不会太复杂),你可以简单地重新格式化提交的表单: ( 'YM-d',的strtotime($ _ POST [ 'userSubmittedBDay']));

并将其作为字符串插入到数据库中。上面的例子会给你格式2011-01-26


I am new to programming, have done a few things but i have no idea how to collect dob information. How do i collect it from a form and how do i insert it? Do i use three fields: month/day/year and then in the db also have three columns?

Is there a tutorial i can be pointed to?

Thanks

解决方案

Depending on what you're going to do with the data (if it's not going to be too complex), you could simply reformat the submitted form:

$bday = date('Y-m-d',strtotime($_POST['userSubmittedBDay']));

and insert that into the database as a string. The above example would give you the format 2011-01-26

这篇关于如何从php表单中收集出生日期并插入到mysql中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 02:30