我有按行存储的歌曲,我想创建一个带有时间戳的播放列表以显示歌曲播放的时间。我的艺术家/歌曲填充得很好,但时间只是显示当前时间。$sql = "SELECT artist, title, starttime FROM radio_playlist_history WHERE name LIKE 'kbac' AND starttime LIKE '$starttime%' ORDER BY starttime DESC";$result = $conn->query($sql);if ($result->num_rows > 0) {// output data of each row $time = end(explode(' ', $row["starttime"])); while($row = $result->fetch_assoc()) { print_r( "<div class='col-sm-6'><h4>Artist: " . $row["artist"]. " <br> Title: " . $row["title"]. "<br>". $time ."</h4></div>"); } } else { print_r ("0 results"); }我可能错过了一些愚蠢的事情。任何帮助我将不胜感激。
1 回答
潇湘沐
TA贡献1816条经验 获得超6个赞
你能试试这个吗?请将以下代码行放入循环中。
$time = end(explode(' ', $row["starttime"]));
最终代码:
$sql = "SELECT artist, title, starttime FROM radio_playlist_history WHERE name LIKE 'kbac' AND starttime LIKE '$starttime%' ORDER BY starttime DESC";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while ($row = $result->fetch_assoc()) {
$time = end(explode(' ', $row["starttime"]));
print_r("<div class='col-sm-6'><h4>Artist: " . $row["artist"] . " <br> Title: " . $row["title"] . "<br>" . $time . "</h4></div>");
}
} else {
print_r("0 results");
}
- 1 回答
- 0 关注
- 112 浏览
添加回答
举报
0/150
提交
取消