我正在尝试从mysql数据库中获取并显示所有用户信息,但它无法显示行上的时间,但可以显示其他信息,如用户ID和用户名。如果我在我的windows localhost中运行系统它只是工作正常但是当我使用网络托管运行它时它没有显示日期。
我目前的编码:
<?php
$sql_select = "SELECT * FROM tbluserinfo";
$result = $conn->query($sql_select);
if ($result->num_rows > 0)
{
while($row = $result->fetch_assoc())
{
echo "<tr>";
echo "<td>".$row['user_id']."</td>";
echo "<td>".$row['user_name']."</td>";
echo "<td>".$row['user_created_date']."</td>";
echo "</tr>";
}
}
else
{
echo "<td colspan='3' style='color: red;'>No record found.</td>";
}
?>
答案 0 :(得分:0)
你可以尝试:
ALTER PROCEDURE [dbo].[GetDataLastValue]
@InstrumentID INT
AS
BEGIN
SELECT
InstrumentId,
c.ChannelId, c.DataTime,
CONVERT(DECIMAL(38, 4), (NumericValue / c.Scale)) AS NumericValue,
c.Diag, ChannelDescription
FROM
dbo.Instrument
LEFT JOIN
(SELECT
ChannelId,
MAX(DateTime) as DataTime,
(SELECT TOP 1 NumericValue
FROM dbo.Datum
WHERE ChannelId = t.ChannelId
ORDER BY DateTime DESC) AS NumericValue,
(SELECT TOP 1 InstrumentId
FROM dbo.Channel
WHERE Channel.ChannelId = t.ChannelId) AS myinst,
(SELECT Scale
FROM dbo.Channel
WHERE Channel.ChannelId = t.ChannelId) AS Scale,
(SELECT Diag
FROM dbo.Channel
WHERE Channel.ChannelId = t.ChannelId) AS Diag,
(SELECT ChannelDescription
FROM dbo.Channel
WHERE Channel.ChannelId = t.ChannelId) AS ChannelDescription
FROM
dbo.Datum as t
GROUP BY ChannelId) c ON c.myinst = Instrument.InstrumentId
WHERE
InstrumentId = @InstrumentID AND c.Diag = 0
ORDER BY
ChannelDescription
END
并确保您的echo date('j F, Y', strtotime($row['user_created_date']));
不为空,否则会为您提供此日期:
$row['user_created_date']