19.10.2023, 14:09
Hab den Fehler gefunden. Das array() der API war falsch strukturiert.
So funktioniert es nun:
So funktioniert es nun:
PHP-Code:
<?php
$rslt = $pdo->query("SHOW TABLES");
$songs_random = array();
while ($db_table = $rslt->fetch(PDO::FETCH_NUM)) {
$sql = "SELECT id, title, textauthor, musicauthor, genre FROM `$db_table[0]` ORDER BY RAND() LIMIT 3";
foreach ($pdo->query($sql) as $row) {
$songs_random[] = array(
'id' => $row['id'],
'title' => $row['title'],
'textauthor' => $row['textauthor'],
'musicauthor' => $row['musicauthor'],
'genre' => $row['genre']
);
}
}