forked from RmK9/Wanderblog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpicture.php
40 lines (31 loc) · 950 Bytes
/
picture.php
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
* Created by PhpStorm.
* User: Sean
* Date: 12/8/2015
* Time: 4:05 PM
*/
require_once 'functions.php'; //Grabs any extra functions
try {
$postID = $_POST['adventureId'];
if ($postID) {
$oConn = loginToDB();
$pictures = array();
//Prepare statement, substitute :username with username field input
$query = $oConn->prepare('SELECT Pictures.Path FROM Pictures WHERE Pictures.PostID = :PostID'); //Query for PostID and any comments it may have
$query->bindValue(':PostID', $postID, PDO::PARAM_STR);
$query->execute();
$rows = $query->fetchAll(PDO::FETCH_ASSOC);
if ($rows) {
echo json_encode($rows);
} else {
echo json_encode(array('error' => 'no pictures found'));
}
}else{
echo 'Adventure not found';
}
}catch (PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
} finally{
$oConn = null;
}