Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $app->get('/markers/?', function () use ($app) {
- $controller = new UFMarkersController($app);
- return $controller->getMarkersJSON();
- });
- <!DOCTYPE html>
- <html lang="en">
- <head>
- {% include 'components/head.html' %}
- </head>
- <body>
- <?php
- include('DB_INFO.php');
- function getMarkersJSON(){
- // Opens a connection to a MySQL server.
- $connection = mysqli_connect($server, $username, $password);
- if (!$connection) {
- die('Not connected : ' . mysqli_error());}
- // Sets the active MySQL database.
- $db_selected = mysqli_select_db($database, $connection);
- if (!$db_selected) {
- die('Can't use db : ' . mysqli_error());}
- // Selects all the rows in the markers table.
- $query = "SELECT * FROM tester WHERE 1";
- $result = mysqli_query($connection, $query);
- if (!$result) {
- die('Invalid query: '. mysqli_error());
- }
- $markers = array();
- while ($row = mysqli_fetch_assoc($result)) {
- //Assuming "lat" is column name in tester table. Please change it if required.
- $lat= $rows['lat'];
- //Assuming "lng" is column name in tester table. Please change it if required.
- $lng= $rows['lng'];
- $markers = array('lat' => $lat, 'lng' => $lng);
- }
- echo json_encode($markers);
- }
- ?>
- </body>
- </html>
- <meta http-equiv="Content-Type" content="text/html;charset=[your-charset]" />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement