예제 #1
0
/**
 * Function to display all sorted wines by name
 */
function sortWineName()
{
    include_once '../models/wine.php';
    $wine = new Wine();
    if ($result = $wine->sortWineName()) {
        $row = $result->fetch_assoc();
        echo '{"result":1, "sortWines": [';
        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."}';
    }
}