PLEASE NOTE: This mod does not display duplicated masteries, as of 2020-03-19. If you would like duplicate masteries to show, it is as simple as finding and removing 'GROUP BY deck' from the select statement.

Select statements call to the database to get the decks that our code is displaying. Each type of display has its own select statement, and can be edited accordingly.

Add this to your mods.php file

// This function allows you to show a single era from an artist
function display_artist_masteries($tcg, $artist, $era = '', $badge = ''){
    $database = new Database;
    $sanitize = new Sanitize;
    $tcg = $sanitize->for_db($tcg);
    
    $tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='$tcg' LIMIT 1");
    $tcgid = $tcginfo['id'];

    // This if statement is for displaying a single era
    if($era !== '' & $badge === ''){
        $result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = '$tcgid' AND `mastered`=1 AND `deck` LIKE '$artist-$era%' GROUP BY `deck` ORDER BY `deck`");
    }

    // This if statement is for displaying a single era WITH the badge specified
    elseif($era !== '' && $badge !== ''){
        $result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = '$tcgid' AND `mastered`=1 AND `deck` LIKE '$artist-$era%' AND `badge` LIKE '$artist-$era%-$badge.png' ORDER BY `deck`");
    }

    // This statement is for displaying masteries from a single era
    else{
        $result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = '$tcgid' AND `mastered`=1 AND `deck` LIKE '$artist-%' GROUP BY `deck` ORDER BY `deck`");
    }
    
    while ( $row = mysqli_fetch_assoc($result) ) { 
        
        $mastered = date('F d, Y', strtotime($row['mastereddate']));
        if ( $row['badge'] !== '' ) { echo '<a href="?mastered='.$row['id'].'"><img src="'.$tcginfo['cardsurl'].''.$row['badge'].'" alt="" title="Mastered '.$mastered.'" /></a> '; }
        elseif(($badge_filter <= 0)&&($row['badge'] ==='')){}
    }
}

Displaying data on your trade post

Display all of the masteries from a single artist (including custom badges):

<?php display_artist_masteries('idolise', 'svt'); ?>

Display all of the masteries from a single era:

<?php display_artist_masteries('idolise', 'svt', 'dontwannacry'); ?>

Display all of the decks from a single era, whose badge named differently:

This code will display all deck masteries from this era that end in 'caitlin'.

For example, svt-dontwannacryjeonghan-caitlin.png — this is great for those who have mastered an era more than once, with the second mastery being made up of custom badges.

<?php display_artist_masteries('idolise', 'svt', 'dontwannacry', 'caitlin'); ?>