function displayImages($dbAdapter)
{
    $gate = new TravelImageTableGateway($dbAdapter);
    if (isset($_GET['go'])) {
        $search = $_GET['go'];
        /* $result = $gate->findBySearch($search); */
        $where = "Title LIKE :searched1 OR Description LIKE :searched2";
        $result = $gate->findBy($where, array(':searched1' => "%" . $search . "%", ':searched2' => "%" . $search . "%"));
    } elseif (isset($_GET['country']) && isset($_GET['city']) && $_GET['country'] != 'ZZZ' && $_GET['city'] != '0') {
        $cityIso = $_GET['city'];
        $countryIso = $_GET['country'];
        $where = 'CountryCodeISO = :countryIso AND CityCode = :cityIso';
        $result = $gate->findBy($where, array(':countryIso' => $countryIso, ':cityIso' => $cityIso));
    } elseif (isset($_GET['city']) && $_GET['city'] == '0' && isset($_GET['country']) && $_GET['country'] != 'ZZZ') {
        $countryIso = $_GET['country'];
        $where = 'CountryCodeISO = :countryIso';
        $result = $gate->findBy($where, array(':countryIso' => $countryIso));
    } elseif (isset($_GET['city']) && ($_GET['country'] == 'ZZZ' && $_GET['city'] != '0')) {
        $cityIso = $_GET['city'];
        $where = 'CityCode = :cityIso';
        $result = $gate->findBy($where, array(':cityIso' => $cityIso));
    } else {
        $result = $gate->findAll();
    }
    if (isset($_GET['go']) && empty($result)) {
        echo "Search returned no results.";
    } else {
        OutputImages($result);
        // called from functions.php
    }
}
function ImagesFrom($countryName, $dbAdapter)
{
    $gate = new TravelImageTableGateway($dbAdapter);
    $countryIso = $_GET['iso'];
    $where = 'CountryCodeISO = :countryIso';
    $result = $gate->findBy($where, array(':countryIso' => $countryIso));
    echo '<div class="panel panel-primary">
		<div class="panel-heading">Images From ' . $countryName . '</div>
			<div class="panel-body">';
    OutputImages($result);
    echo '</div>
		</div>';
}
function outputThumbnail($dbAdapter)
{
    $gateTravelImage = new TravelImageTableGateway($dbAdapter);
    $result = $gateTravelImage->findForPost($_GET['id']);
    OutputImages($result);
}
function outputUserImages($dbAdapter)
{
    $gateTravelImage = new TravelImageTableGateway($dbAdapter);
    $result = $gateTravelImage->findForUser($_GET['id']);
    OutputImages($result);
}