function outputCountriesWithVisits($dbAdapter) { $id = $_GET[continent]; if (!empty($id) && !is_numeric($id) && strlen($id) == 2 && ctype_upper($id)) { $gateCountry = new CountryTableGateway($dbAdapter); $result = $gateCountry->findCountriesWithCountsById($id); echo '<table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp"> <thead> <tr> <th class="mdl-data-table__cell--non-numeric">Country</th> <th>Visits</th> </tr> </thead> <tbody>'; foreach ($result as $row) { echo '<tr> <td class="mdl-data-table__cell--non-numeric">' . $row->CountryName . '</td> <td>' . $row->VisitsFromCountry . '</td> </tr>'; } echo '</tbody> </table>'; } else { echo "<h2>Chosen continent does not exist</h2>"; } }
function outputCountries($dbAdapter) { $gate = new CountryTableGateway($dbAdapter); $result = $gate->findCountriesWithImages(); foreach ($result as $row) { echo '<li class="list-group-item"> <a href="single-country.php?iso=' . $row->ISO . '">' . $row->CountryName . '</a></li>'; } }
function filterCountry($dbAdapter) { $gate = new CountryTableGateway($dbAdapter); $result = $gate->findCountriesWithImages(); foreach ($result as $row) { echo '<option value="' . $row->ISO . '">'; echo $row->CountryName; echo '</option>'; } }
function outputContent($dbAdapter) { $gate = new CountryTableGateway($dbAdapter); $result = $gate->findById($_GET['iso']); echo utf8_encode('<ol class="breadcrumb"> <li><a href="index.php">Home</a></li> <li><a href="browse.php">Browse</a></li> <li><a href="browse-countries.php">Countries</a></li> <li class="active">' . $result->CountryName . '</li> </ol>'); echo '<div class="panel panel-default"> <div class="panel-body">'; echo utf8_encode('<h2>' . $result->CountryName . '</h2> <p>Capital: <b>' . $result->Capital . '</b></p> <p>Area: <b>' . number_format($result->Area) . '</b> sq km.</p> <p>Population: <b>' . number_format($result->Population) . '</b></p> <p>Currency Name: <b>' . $result->CurrencyName . '</b></p> <p>' . $result->CountryDescription . '</p>'); echo '</div> </div>'; ImagesFrom($result->CountryName, $dbAdapter); }
function ImageDetailsPanel($cityCode, $countryCode, $dbAdapter) { $gateCountry = new CountryTableGateway($dbAdapter); $gateCity = new CityTableGateway($dbAdapter); $cityName = $gateCity->findById($cityCode)->AsciiName; $countryName = $gateCountry->findById($countryCode)->CountryName; $countryCodeISO = $gateCountry->findById($countryCode)->CountryCodeISO; echo '<div class="panel panel-info"> <div class="panel-heading">Image Details</div> <div class="panel-body">'; echo utf8_encode('<p>' . $cityName . ', <a href="single-country.php?iso=' . $countryCode . '">' . $countryName . '</a></p>'); echo '</div> </div>'; }
function outputCountriesByContinent($dbAdapter) { $userContinent = $_GET["continentCode"]; $countryGate = new CountryTableGateway($dbAdapter); $result = $countryGate->findCountriesWithCountsById($userContinent); $countryInfoArray = []; foreach ($result as $row) { $countryInfo = new stdClass(); $countryInfo->name = $row->CountryName; $countryInfo->visitCount = $row->VisitsFromCountry; array_push($countryInfoArray, $countryInfo); } echo json_encode($countryInfoArray); }