It's 2020 and counting coins is outdated. Subtracting and adding to your card count is tedious and we know that you guys hate it. We've changed the way that we give you currency to make things a little easier, and this is just a quick mod to help you display your currency from a category.
function show_currency( $tcg, $category ) {
$database = new Database;
$sanitize = new Sanitize;
$tcg = $sanitize->for_db($tcg);
$category = $sanitize->for_db($category);
$altname = strtolower(str_replace(' ','',$tcg));
$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='$tcg' LIMIT 1");
$tcgid = $tcginfo['id'];
$cardsurl = $tcginfo['cardsurl'];
$format = $tcginfo['format'];
$cards = $database->get_assoc("SELECT `cards`, `format` FROM `cards` WHERE `tcg`='$tcgid' AND `category`='$category' LIMIT 1");
if ( $cards['cards'] === '' ) { $cards['cards'] = []; }
$cards = explode(',',$cards['cards']);
$cards = array_map(trim, $cards);
$gold_count = 0;
$gem_count = 0;
foreach($cards as $currency){
if($currency == 'gold'){
$gold_count++;
}
elseif($currency == 'gem'){
$gem_count++;
}
}
echo '<img src="<http://idolise.letstrade.cards/img/coins.png>"> x '.$gold_count.'<br>';
echo '<img src="<http://idolise.letstrade.cards/img/gems.png>"> x '.$gem_count.'<br>';
}
For the purpose of this, I've created a category called 'currency' (but you can call it anything you'd like), and I've put a couple of currency into it.
<?php show_currency('idolise', 'currency'); ?>