I've been trying to make a simple video list system for my website, and I can't get this working.
$buffer = explode("|", $playlist['videos']);
$id = 0;
foreach($buffer as $key) {
if(!empty($key)) {
$id++;
$video = getVideoFromId($key, $conn);
print_r($video);
getVideoFromId
function getVideoFromId($id, $connection) {
$stmt = $connection->prepare("SELECT * FROM videos WHERE rid = ?");
$stmt->bind_param("s", $id);
$stmt->execute();
$result = $stmt->get_result();
$video = $result->fetch_assoc();
$stmt->close();
return $video;
}
It seems to completely ignore it, buffer is not empty because when I print_r'd it, it outputted the stuff that I needed. $playlist is a function named getPlaylistFromID.
getPlaylistFromId
function getPlaylistFromID($id, $connection) {
$stmt = $connection->prepare("SELECT * FROM playlists WHERE rid = ?");
$stmt->bind_param("s", $id);
$stmt->execute();
$result = $stmt->get_result();
$playlist = $result->fetch_assoc();
$stmt->close();
return $playlist;
}
$key is the video ID, and $video is an array of the video containing all the data like the title, description, and whatnot.
$buffer is usually a video id seperated by |, for example: |MTYxMTUxNzE2MzQ=47|MTYxMTUxNzE2MzQ=47|MTYxMTUxNzE2MzQ=47|MTYxMTUxNzE2MzQ=47|MTYxMTUxNzE2MzQ=47|MTYxMTUxNzE2MzQ=47
is the format it is in.