Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class PickupPoint {
- public $loc_id = 0;
- public $latitude = 1.0;
- public $longitude = 10.0;
- public $points = 0;
- }
- $loc = new PickupPoint();
- $loc->loc_id = 0;
- $loc->latitude = 5.0;
- $loc->longitude = 10.0;
- $loc->points = 0;
- $locs = array($loc, $loc); //add more points
- echo json_encode($locs);
- $servername = "localhost";
- $username = "starfeesh";
- $password = "norissa9";
- $dbname = "uniridersdb";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT loc_id, latitude, longitude, points FROM locations";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- $loc = new PickupPoint();
- $loc->loc_id = $row["loc_id"];
- $loc->latitude = $row["latitude"];
- $loc->longitude = $row["longitude"];
- $loc->points = $row["points"];
- }
- } else {
- echo "0 results";
- }
- $conn->close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement