Utklippstavle
Valgmuligheter
DavidS sendte inn denne php-koden 25.02.2010 kl. 14:26.
<?php /** * Request zip code or place from database * based on result from AJAX * * @author David Steinsland * @url http://davidsteinsland.net * @license Creative Commons Attribution-Share Alike 3.0 Unported License * @license url http://creativecommons.org/licenses/by-sa/3.0/ */ } // Retrieve and validate the input. if (!$Query) { } // stores cache for 24 hours die; } // Connect to the MySQL database. // Tell MySQL to use UTF-8. // Check if it's set correctly. $Where = 'z.zip = ' . $Query; } else { $Where = 'p.name = "' . $Query . '"'; } // Run the query against the database. $SQL = "SELECT c.name as fylke, m.name as kommune, p.name as poststed, z.zip, z.lat, z.lon FROM zip_places p INNER JOIN zip_codes z ON z.place_id = p.place_id INNER JOIN munincipial m ON m.id = p.munincipial_id INNER JOIN county c ON c.county_id = m.county_id WHERE $Where LIMIT 1"; } // Fetch the result. $JSON = json_encode($Data); file_put_contents ($Cache, $JSON); echo $JSON; ?>
Emneord (tags): php, postal, ajax, postnummer
