简体   繁体   中英

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. 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. 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代码。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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