Get Category | v1.0 | etcgfm v1.0.1 | up 10.18.13

  1. 5 years ago

    Required Mods
    None

    Purpose
    This is really just a basic mod that you'll need for some of my other mods. It's just like "get_additional", but for categories instead of additional fields. It pulls the card list from a category without doing anything to them.

    Function
    This goes into your func.php, custom function page.

    function get_category( $tcg, $category) {
    
    	$database = new Database;
    	$sanitize = new Sanitize;
    	$tcg = $sanitize->for_db($tcg);
    	$category = $sanitize->for_db($category);
    	$altname = strtolower(str_replace(' ','',$tcg));
    
    	$result = $database->get_assoc("SELECT `id` FROM `tcgs` WHERE `name`='$tcg' LIMIT 1");
    	$tcgid = $result['id'];
    	
    	$result = $database->get_assoc("SELECT `cards` FROM `cards` WHERE `tcg`='$tcgid' AND 
    
    `category`='$category' LIMIT 1");
    	return $result['cards'];
    
    }

    Execution
    You probably won't need to use this function directly, but if you're interested in making a mod, use:

    get_category( $tcg, $category);

    You can set it to a variable (ex: $cards = get_category...), or if you just want a list of cards up for some reason, just use "echo get_category..."

    The reqired variables to change are $tcg, to whatever TCG you're using it on and $category to whatever category you're using it on.

    There are no optional categories.

    Upcoming Versions
    Nothing planned, but if people have any suggestions, feel free to offer them.

or Sign Up to reply!