<?php
    require_once("../../php/db_utils.php");
    
    try {
        // Connect to the database
        $database = databaseConnect();
        
        // Incoming data
        $tag = $_POST["tag"];
        $username = $_POST["username"];
        
        // Declare query
        $query = "SELECT description FROM tags WHERE tag = '" . $tag . "' AND username = '" . $username . "';";
        
        // Run query
        $recordSet = databaseQueryWithReturn($database, $query);
        
        // Get description for the selected tag
        $record = mysqli_fetch_assoc($recordSet);
        
        $description = $record["description"];
        
        mysqli_free_result($recordSet);
        
        echo($description);
        
        // Close the connection to the database
        databaseClose($database);
    }
    catch(Exception $e) {
        $errorMsg = $e->getMessage();
        print_r($errorMsg);
    }
?>