I'm trying to create a system that uses images from LastFM. But I want to show only the images of the artists registered in the bank. I did so:
I made a query of the bank with condition that banda_id was not null.
I created a foreach to get the data.
I created another foreach inside the previous foreach by picking up the band name and setting to receive the API image.
Does it work? I say yes, but it has a delay and I even understand foreach's and queries too much , but it was the only way to get it going.
I wanted to see you, if there was any way I could get all the data without having to loop to get the data.
I'm open to suggestions for improvement, I'm almost certain that I'm doing something wrong, so all help is welcome.
<?php
$getPag = (!empty($Link->getLocal()[1]) ? $Link->getLocal()[1] : 0);
$Pagina = new Pager(HOME . '/bandas/');
$Pagina->ExePagina($getPag, 12);
$lerbanda = new Ler;
$lerbanda->ExeLer("ws_bands", "WHERE band_parent IS NOT NULL ORDER BY band_date DESC LIMIT :limit OFFSET :offset", "limit={$Pagina->getLimit()}&offset={$Pagina->getOffset()}");
if (!$lerbanda->getResult()):
$Pager->ReturnPage();
WSErro("Desculpe, não existem bandas cadastradas no momento, favor volte mais tarde!", WS_INFOR);
else:
echo'<div class="banda_news">';
echo'<div class="grid-row">';
foreach ($lerbanda->getResult() as $banda):
echo "<img src=\"";
echo LastFMArtwork::getArtwork($banda['band_title'],true, "mega");
echo "\">";
endforeach;
echo '</div>';
echo '</div>';
endif;
$Pagina->ExePaginar("ws_bands", "ORDER BY band_date");
echo $Pagina->getPagina();
?>
API Class
/ p>