function fetchMunicipalities($municipalities) { $query = "SELECT * FROM municipalities group by name order by name"; $result = mysqlQuery($query); while ($row = mysqlFetchArray($result)) { $municipalities[$row["id"]] = $row["name"]; } return $municipalities; }
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty * * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this software. If not, see <http://www.gnu.org/licenses/>. * * * * index.php: * * Display the fair trade finder map. * * * **************************************************************************/ // General includes include '../config.php'; include '../functions.php'; // Set up templating system require_once "../smarty/Smarty.class.php"; $smarty = new Smarty(); $smarty->template_dir = '../templates'; $smarty->compile_dir = '../smarty/templates_c'; $smarty->cache_dir = '../smarty/cache'; $smarty->config_dir = '.'; $smarty->caching = 0; $smarty->assign('base', $base); if ($input && is_numeric($input)) { $rowID = $input; $municipality = mysqlFetchArray(mysqlQuery("SELECT * FROM municipalities WHERE id='%s'", $rowID)); $smarty->assign("municipality", $municipality); $smarty->assign("input", $input); } $smarty->assign("body", 'list.html'); $smarty->display("wrapper.html");
* GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this software. If not, see <http://www.gnu.org/licenses/>. * * * * index.php: * * Display the fair trade finder map. * * * **************************************************************************/ // General includes include '../config.php'; include '../functions.php'; // Set up templating system require_once "../smarty/Smarty.class.php"; $smarty = new Smarty(); $smarty->template_dir = '../templates'; $smarty->compile_dir = '../smarty/templates_c'; $smarty->cache_dir = '../smarty/cache'; $smarty->config_dir = '.'; $smarty->caching = 0; $smarty->assign('base', $base); $municipalities = array("" => "Select a city..."); $municipalities = fetchMunicipalities($municipalities); $smarty->assign('municipalities', $municipalities); if ($input && is_numeric($input)) { $rowID = $input; $location = mysqlFetchArray(mysqlQuery("SELECT * FROM locations WHERE id=%s", $rowID)); $smarty->assign("location", $location); } $smarty->assign("body", 'list.html'); $smarty->display("wrapper.html");
<?php if ($_POST['id'] && is_numeric($_POST['id'])) { $redirect_URL = $base . "/view/list"; $rowID = $_POST['id']; $gid = mysqlFetchArray(mysqlQuery("SELECT geoCodeId FROM locations WHERE id=%s", $rowID)); mysqlQuery("DELETE FROM locations WHERE id=%s", $rowID); mysqlQuery("DELETE FROM geocodes WHERE id=%s", $gid); $message = "Location Removed."; } else { $message = "error"; } $_SESSION['msg'] = $message; // Could use an array if more than one message was needed simultaneously. header('Location: ' . $redirect_URL); exit;
$limit = 40; } } // else...? (shouldn't need one) // Decide on sorting... by distance if doing a proximity search; by name // if displaying all locations on screen if ($locSearch || $getLat && $getLng) { $pointsQuery .= " ORDER BY distance"; } else { // Can we find the point of the map centre, and still sort by distance? $pointsQuery .= " ORDER BY locations.name"; } $pointsQuery .= " LIMIT 0, " . $limit; // Finally, run the query $gArray = mysqlResultAsArray($pointsQuery); $rnum = mysqlFetchArray(mysqlQuery("SELECT FOUND_ROWS()")); // Prepare to output as XML document $doc = new DOMDocument('1.0'); $doc->formatOutput = true; $node = $doc->createElement("xmlData"); $parnode = $doc->appendChild($node); // Add pagination information (ie, if more results were available but the // SQL LIMIT statement kicked in...) if ($rnum[0]) { $node = $doc->createElement("results"); $newnode = $parnode->appendChild($node); if ($limit < count($gArray)) { $newnode->setAttribute("displayed", $limit); } else { $newnode->setAttribute("displayed", count($gArray)); }