我有按行存儲的歌曲,我想創建一個帶有時間戳的播放列表以顯示歌曲播放的時間。我的藝術家/歌曲填充得很好,但時間只是顯示當前時間。$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 關注
- 137 瀏覽
添加回答
舉報
0/150
提交
取消