Skip to content

Commit

Permalink
Merge pull request #894 from wrongecho/locations-api
Browse files Browse the repository at this point in the history
Add locations read api endpoint
  • Loading branch information
johnnyq authored Feb 24, 2024
2 parents d318fff + 54e015b commit e1b29df
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions api/v1/locations/read.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

require_once '../validate_api_key.php';

require_once '../require_get_method.php';


if (isset($_GET['location_id'])) {
// Location via ID (single)

$id = intval($_GET['location_id']);
$sql = mysqli_query($mysqli, "SELECT * FROM locations WHERE location_id = '$id' AND location_client_id LIKE '$client_id'");

} else {
// All locations

$sql = mysqli_query($mysqli, "SELECT * FROM locations WHERE location_client_id LIKE '$client_id' ORDER BY location_id LIMIT $limit OFFSET $offset");
}

// Output
require_once "../read_output.php";

0 comments on commit e1b29df

Please sign in to comment.