/**
 * Function to display all tasks
 */
function displayWineByType()
{
    if (isset($_REQUEST['wineType'])) {
        include_once '../models/wine.php';
        $wine = new Wine();
        $wineType = $_REQUEST['wineType'];
        if ($result = $wine->displayWineByType($wineType)) {
            $row = $result->fetch_assoc();
            echo '{"result":1, "wines": [';
            while ($row) {
                echo '{"wine_id": "' . $row["wine_id"] . '", "wine_name": "' . $row["wine_name"] . '",
            "winery_name": "' . $row["winery_name"] . '", "cost": "' . $row["cost"] . '",
            "wine_type": "' . $row["wine_type"] . '", "year": "' . $row["year"] . '"}';
                if ($row = $result->fetch_assoc()) {
                    echo ',';
                }
            }
            echo ']}';
        } else {
            echo '{"result":0,"status": "An error occurred for display wines."}';
        }
    }
}