Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "username";
- $password = "password";
- $dbname = "myDB";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if( $conn->connect_error ) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT `coordinates` FROM `MedMandatabase`";
- $result = $conn->query($sql);
- if( $result->num_rows > 0 ) {
- // Create output base
- $output = "<script> var locations = [";
- // output data of each row
- while( $row = $result->fetch_assoc() ) {
- echo "\"{$row['location']}\", ";
- }
- // Create output last and print
- $output = substr($output, 0, -2);
- $output .= "];</script>";
- echo $output;
- } else {
- echo "0 results";
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement