[英]Associate Time with SQL Row
我有按行存储的歌曲,我想创建一个带有时间戳的播放列表,以显示歌曲播放的时间。 我的艺术家/歌曲填充得很好,但时间只是显示当前时间。
$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");
}
我可能错过了一些愚蠢的东西。 任何帮助我都会很感激。
你能试试这个吗? 请将以下代码行放入循环中。
$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");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.