[英]change mysql datetime to php datetime-local not working by strtotime()
I have mysql table with datatime type and i want it to show in php/html table 我有datatime类型的mysql表,我希望它显示在php / html表中
while($row = mysqli_fetch_assoc($result)) {
$time1 = strtotime($row["Request Date"]);
$myFormatForView = date("d/m/y g:i A", $time1);
output 输出
11/02/15 10:18 AM
now i tried this code to work with html table 现在我尝试使用此代码与html表一起使用
<td> <input type='datetime-local' id='txt_dateid_".$i."' value=".$myFormatForView." disabled></td>
but i am not getting any output 但我没有任何输出
full code 完整的代码
<?php
include_once "connector.php";
$sql = "SELECT * FROM $tablename";
$result = mysqli_query($db,$sql);
$i=0;
$row=0;
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
$time1 = strtotime($row["Request Date"]);
$myFormatForView = date("d/m/y g:i A", $time1);
echo ($myFormatForView);
echo
"
<tr>
<td size='20' align='center'> <input type='text' id='txt_orderid_".$i."'value=" . $row["Order ID"]. " disabled> </td>
<td> <button type='button' id='btn_update_".$i."' onclick='myFunction($i)'>update</button> </td>
<td> <button type='button' id='btn_delete_".$i."' onclick='DeleteFunction($i)'>delete</button> </td>
<td> <input type='datetime-local' id='txt_dateid_".$i."'value=" . $myFormatForView. " disabled></td>
<td> <input type='text' id='txt_timeid_".$i."'class='txt_id_".$i."' value=" . $row["Fixed Time"]. " disabled></td>
<td> <input type='text' id='txt_toolid_".$i."' class='txt_id_".$i."' value=" . $row["Tool"]. " disabled> </td>
<td> <input type='text' id='txt_nameid_".$i."' class='txt_id_".$i."' value=" . $row["Name"]. " disabled> </td>
<td> <input type='text' id='txt_emailid_".$i."' class='txt_id_".$i."' value=" . $row["Email"]. " disabled> </td>
<td> <input type='text' id='txt_countid_".$i."' class='txt_id_".$i."' value=" . $row["Country Entered"]. " disabled> </td>
</tr>
";
$i++;
}
edit 1 : 编辑1:
this code also does not work 此代码也不起作用
<td> <input type='datetime-local' id='txt_dateid_".$i."' 'value'=".$myFormatForView." disabled></td>
Edit 2: 编辑2:
Error Spotted you haven't put quotes in value ''
. 发现错误您没有在值''
加上引号。 Use this 用这个
<td> <input type='datetime-local' id='txt_dateid_".$i."' value='".$myFormatForView."' disabled></td>
Hope this helps you 希望这对您有帮助
You have there missing spaces between attributes ( id
and value
) and missing quotes around the value
attribute: 属性( id
和value
)之间缺少空格,而value
属性周围缺少引号:
<td>
<input type='datetime-local' id='txt_dateid_" . $i . "' value='" . $myFormatForView . "' disabled>
</td>
Note: for better reading I've indented input
in td
and put there optinal spaces around dots .
注意:为了更好地阅读,我在td
缩进了input
,并在点周围放置了最佳空格.
. 。
you have mistaken here 你在这里弄错了
<td> <input type='datetime-local' id='txt_dateid_".$i." 'value=".$myFormatForView." disabled></td>
replace this line with below one 用下面的一行代替
<td> <input type='datetime-local' id='txt_dateid_".$i."' 'value='".$myFormatForView."' disabled></td>
You have missed the quotes for value attribute. 您已经错过了价值属性的引号。 Try this: 尝试这个:
<td> <input type='datetime-local' id='txt_dateid_".$i."' value='".$myFormatForView."' disabled></td>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.