Select my location

I am creating websites

<li>
<?php
if (isset($_COOKIE['location']['city']) && !empty($_COOKIE['location']['city'])) {
echo '<a href="#" id="select_location"><i class="fa fa-fw fa-map-marker"></i>' . $_COOKIE['location']['city'] . ' <i class="fa fa-fw fa-chevron-down"></i></a>';
} else {
if (isset($_COOKIE['location']['region']) && !empty($_COOKIE['location']['region'])) {
echo '<a href="#" id="select_location"><i class="fa fa-fw fa-map-marker"></i>' . $_COOKIE['location']['region'] . ' <i class="fa fa-fw fa-chevron-down"></i></a>';
} else {
echo '<a href="#" id="select_location">Select my location <i class="fa fa-fw fa-chevron-down"></i></a>';
}
}
?>
<div id="locationSelector" style="display: none;">
<form id="locationForm" class="form form-horizontal" role="form" method="post">
<div class="form-group">
<div id="select_country_wrapper">
<?php
$qco = $dbh->query("SELECT DISTINCT country_name FROM locations ORDER BY country_name ASC") or die ('MySQL error (' . $dbh->errno . '): ' . $dbh->error . ' in ' . basename(__FILE__) . ' line ' . __LINE__);
$cco = $qco->num_rows;
if ($cco > 1) {
$qfco = $dbh->query("SELECT DISTINCT country_name FROM locations ORDER BY country_name ASC LIMIT 0,1") or die ('MySQL error (' . $dbh->errno . '): ' . $dbh->error . ' in ' . basename(__FILE__) . ' line ' . __LINE__);
$rfco = $qfco->fetch_assoc();
$firstCountry = $rfco['country_name'];
}
?>
<select name="select_country" class="form-control">
<option value="">All countries</option>
<?php while ($rco = $qco->fetch_assoc()): ?>
<option value="<?php echo $rco['country_name'];?>"><?php echo $rco['country_name'];?></option>
<?php endwhile; ?>
</select>
</div>
<div class="spacer-xs"></div>
<div id="select_region_wrapper">
<select name="select_region" class="form-control">
<option value="">All regions</option>
<?php
$qr = $dbh->query("SELECT DISTINCT region_name FROM canada_cities ORDER BY region_name ASC") or die ('MySQL error (' . $dbh->errno . '): ' . $dbh->error . ' in ' . basename(__FILE__) . ' line ' . __LINE__);
while ($rr = $qr->fetch_assoc()) {
echo '<option value="' . $rr['region_name'] . '"'; if (isset($_COOKIE['location']) && $_COOKIE['location']['region'] == $rr['region_name']) { echo ' selected="selected"'; } echo '>' . $rr['region_name'] . '</option>';
}
?>
</select>
</div>
<div class="spacer-xs"></div>
<div id="select_city_wrapper">
<select name="select_city" class="form-control">
<option value="">Select city:</option>
<?php
if (!isset($_COOKIE['location'])) {
$qfr = $dbh->query("SELECT DISTINCT region_name FROM canada_cities ORDER BY region_name ASC LIMIT 0,1") or die ('MySQL error (' . $dbh->errno . '): ' . $dbh->error . ' in ' . basename(__FILE__) . ' line ' . __LINE__);
$rfr = $qfr->fetch_assoc();
$qc = $dbh->query("SELECT * FROM canada_cities WHERE region_name = '" . $rfr['region_name'] . "'") or die ('MySQL error (' . $dbh->errno . '): ' . $dbh->error . ' in ' . basename(__FILE__) . ' line ' . __LINE__);
while ($rc = $qc->fetch_assoc()) {
echo '<option value="' . $rc['city_name'] . '"'; if (isset($_COOKIE['location']) && $_COOKIE['location']['city'] == $rc['city_name']) { echo ' selected="selected"'; } echo '>' . $rc['city_name'] . '</option>';
}
} else {
$region = $dbh->real_escape_string($_COOKIE['location']['region']);
$qc = $dbh->query("SELECT * FROM canada_cities WHERE region_name = '$region'") or die ('MySQL error (' . $dbh->errno . '): ' . $dbh->error . ' in ' . basename(__FILE__) . ' line ' . __LINE__);
while ($rc = $qc->fetch_assoc()) {
echo '<option value="' . $rc['city_name'] . '"'; if (isset($_COOKIE['location']) && $_COOKIE['location']['city'] == $rc['city_name']) { echo ' selected="selected"'; } echo '>' . $rc['city_name'] . '</option>';
}
}
?>
</select>
</div>
</div>
<div class="form-group center">
<input type="submit" class="btn btn-info" value="Update">
</div>
</form>
</div>
</li> <li>
<?php
if (isset($_COOKIE['location']['city']) && !empty($_COOKIE['location']['city'])) {
echo '<a href="#" id="select_location"><i class="fa fa-fw fa-map-marker"></i>' . $_COOKIE['location']['city'] . ' <i class="fa fa-fw fa-chevron-down"></i></a>';
} else {
if (isset($_COOKIE['location']['region']) && !empty($_COOKIE['location']['region'])) {
echo '<a href="#" id="select_location"><i class="fa fa-fw fa-map-marker"></i>' . $_COOKIE['location']['region'] . ' <i class="fa fa-fw fa-chevron-down"></i></a>';
} else {
echo '<a href="#" id="select_location">Select my location <i class="fa fa-fw fa-chevron-down"></i></a>';
}
}
?>
<div id="locationSelector" style="display: none;">
<form id="locationForm" class="form form-horizontal" role="form" method="post">
<div class="form-group">
<div id="select_country_wrapper">
<?php
$qco = $dbh->query("SELECT DISTINCT country_name FROM locations ORDER BY country_name ASC") or die ('MySQL error (' . $dbh->errno . '): ' . $dbh->error . ' in ' . basename(__FILE__) . ' line ' . __LINE__);
$cco = $qco->num_rows;
if ($cco > 1) {
$qfco = $dbh->query("SELECT DISTINCT country_name FROM locations ORDER BY country_name ASC LIMIT 0,1") or die ('MySQL error (' . $dbh->errno . '): ' . $dbh->error . ' in ' . basename(__FILE__) . ' line ' . __LINE__);
$rfco = $qfco->fetch_assoc();
$firstCountry = $rfco['country_name'];
}
?>
<select name="select_country" class="form-control">
<option value="">All countries</option>
<?php while ($rco = $qco->fetch_assoc()): ?>
<option value="<?php echo $rco['country_name'];?>"><?php echo $rco['country_name'];?></option>
<?php endwhile; ?>
</select>
</div>
<div class="spacer-xs"></div>
<div id="select_region_wrapper">
<select name="select_region" class="form-control">
<option value="">All regions</option>
<?php
$qr = $dbh->query("SELECT DISTINCT region_name FROM canada_cities ORDER BY region_name ASC") or die ('MySQL error (' . $dbh->errno . '): ' . $dbh->error . ' in ' . basename(__FILE__) . ' line ' . __LINE__);
while ($rr = $qr->fetch_assoc()) {
echo '<option value="' . $rr['region_name'] . '"'; if (isset($_COOKIE['location']) && $_COOKIE['location']['region'] == $rr['region_name']) { echo ' selected="selected"'; } echo '>' . $rr['region_name'] . '</option>';
}
?>
</select>
</div>
<div class="spacer-xs"></div>
<div id="select_city_wrapper">
<select name="select_city" class="form-control">
<option value="">Select city:</option>
<?php
if (!isset($_COOKIE['location'])) {
$qfr = $dbh->query("SELECT DISTINCT region_name FROM canada_cities ORDER BY region_name ASC LIMIT 0,1") or die ('MySQL error (' . $dbh->errno . '): ' . $dbh->error . ' in ' . basename(__FILE__) . ' line ' . __LINE__);
$rfr = $qfr->fetch_assoc();
$qc = $dbh->query("SELECT * FROM canada_cities WHERE region_name = '" . $rfr['region_name'] . "'") or die ('MySQL error (' . $dbh->errno . '): ' . $dbh->error . ' in ' . basename(__FILE__) . ' line ' . __LINE__);
while ($rc = $qc->fetch_assoc()) {
echo '<option value="' . $rc['city_name'] . '"'; if (isset($_COOKIE['location']) && $_COOKIE['location']['city'] == $rc['city_name']) { echo ' selected="selected"'; } echo '>' . $rc['city_name'] . '</option>';
}
} else {
$region = $dbh->real_escape_string($_COOKIE['location']['region']);
$qc = $dbh->query("SELECT * FROM canada_cities WHERE region_name = '$region'") or die ('MySQL error (' . $dbh->errno . '): ' . $dbh->error . ' in ' . basename(__FILE__) . ' line ' . __LINE__);
while ($rc = $qc->fetch_assoc()) {
echo '<option value="' . $rc['city_name'] . '"'; if (isset($_COOKIE['location']) && $_COOKIE['location']['city'] == $rc['city_name']) { echo ' selected="selected"'; } echo '>' . $rc['city_name'] . '</option>';
}
}
?>
</select>
</div>
</div>
<div class="form-group center">
<input type="submit" class="btn btn-info" value="Update">
</div>
</form>
</div>
</li>

ID: 66
Status: OPEN
Location: Romania, Alba, Alba Iulia
Listed: 150 weeks ago
Deadline:
Views: 385
Attached files:
· 1411948706_CantDIY_test_cases_and_review.pdf [ application/pdf ]

User's profile & reputation


CONTACT POSTER by [mrjaunty]
member since [Apr 09, 2015]
Poster rating: NOT RATED YET
Bidder rating:

Config: 0.001, Controller: 0.001, Functions: 0.001, Head: 0.001, Header: 0.002, Page: 0.013, Footer: 0.013