简体   繁体   English

如何从MySQL中提取日期时间字段的值

[英]how to pull in value of datetime field from mysql

I have the below input fields and I am trying to pull in the datetime from start_date and end_date from my database. 我有以下输入字段,并且我试图从数据库的start_date和end_date提取日期时间。 however when I do the code as shown below it just pulls in blank dates. 但是,当我执行如下所示的代码时,它只会输入空白日期。 I checked the values of the $start_date and $end_date and they are valid. 我检查了$start_date$end_date的值,它们是有效的。 Please let me know what could be wrong. 请让我知道可能有什么问题。

echo 'Start Date:'
    , '<input id="evfinal" type="datetime-local" name="sdate" value="' . $row['start_date'] . '" />'
    , 'End Date:','<input id="evfinal" type="datetime-local" name="edate" value="' . $row['end_date'] . '" />';

code to pull data: 提取数据的代码:

$result = mysql_query("SELECT a.* FROM events a INNER JOIN (SELECT id_user, MAX(event_id) as maxID FROM events GROUP BY id_user) b ON a.id_user = b.id_user AND a.event_id = b.maxID WHERE a.id_user = '25'")
or die(mysql_error()); 


// store the record of the "example" table into $row
while($row = mysql_fetch_array($result)){

尝试这种方式: value="<?php echo $row['start_date']; ?>"尽量避免使用php打印静态html代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM