-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueryDatabase.php
More file actions
25 lines (22 loc) · 824 Bytes
/
QueryDatabase.php
File metadata and controls
25 lines (22 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?
session_start();
mysql_connect('mysql-user-master.stanford.edu', 'ccs147goizueta', 'nookohte');//database connection
mysql_select_db("c_cs147_goizueta");
$Username = $_SESSION['Username'];
$Latitude = $_GET['latitude'];
$Longitude = $_GET['longitude'];
$query = "SELECT *
FROM Pinches
WHERE Datetime = (
SELECT MAX(Datetime)
FROM Pinches)";
/*$query = "SELECT * , SQRT( POW( 69.1 * ( Latitude -$Latitude ) , 2 ) + POW( 69.1 * ($Longitude - Longitude ) * COS( Latitude / 57.3 ) , 2 ) ) AS distance
FROM Pinches
WHERE Latitude IS NOT NULL
ORDER BY distance, Datetime DESC
LIMIT 1";
*/
$result = mysql_query($query); //Needs to check that it's only 1 row. I think this just grabs the first one.
$row = mysql_fetch_assoc($result);
echo json_encode(array("url" => $row['Photo'], "id" => $row['GUID']));
?>