I'm going to focus on your second problem now:
PHP Code:
while ($musical =$db->fetch_array($musicalbum))
{
$malbumid = $musical['alid'];
$malbumname = $musical['alname'];
$malbumarname = $musical['arname'];
$malbumarid = $musical['arid'];
$mcvrsaved = $musical['cvrsaved'];
}
You're only going to get one value doing that because you're overwriting the variable each time.
PHP Code:
$musicals = array();
if ($db->num_rows($musicalbum))
{
while ($musical = $db->fetch_array($musicalbum))
{
$musicals[] = $musical;
}
}
$db->free_result($musicalbum);
Now we're cooking.
I've replace your unnecessary variables with an array and, furthermore, I've made sure each row gets it own place in the array.
PHP Code:
$musicstat = $db->query_read("SELECT nr_artists, nr_albums,nr_tracks FROM " . TABLE_PREFIX ." stats");
while ($music_stat = $db->fetch_array($musicstat))
{
$statar = $music_stat['nr_artists'];
$statal = $music_stat['nr_albums'];
$statt = $music_stat['nr_tracks'];
}
Think you can figure out how to fix this?
Now replace all that ugliness in your first template render with:
PHP Code:
$templater->register('musicals', $musicals);
Now you have an array of all the albums ready for display.
I'd recommend using {vb:each [, ]} to loop through that array and do that.
Read my article, it should help you get the basics down:
https://vborg.vbsupport.ru/showthread.php?t=280880