| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/laragon/www/bpkd/api/ |
Upload File : |
<?php
// SET HEADER
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: access");
header("Access-Control-Allow-Methods: GET");
header("Access-Control-Allow-Credentials: true");
header("Content-Type: application/json; charset=UTF-8");
// INCLUDING DATABASE AND MAKING OBJECT
require 'database.php';
$db_connection = new Database();
$conn = $db_connection->dbConnection();
// CHECK GET ID PARAMETER OR NOT
if(isset($_GET['jenislap'])){
$post_grup = $_GET['jenislap'];
//$clausul = " where grup='.$post_grup.' order by id_download asc";
// MAKE SQL QUERY
// IF GET POSTS ID, THEN SHOW POSTS BY ID OTHERWISE SHOW ALL POSTS
$sql = "SELECT id_download,judul,nama_file as pathfiles,grup FROM download2 where grup LIKE '".$post_grup."' order by id_download asc";
}else{
//$clausul = "";
$sql = "SELECT id_download,judul,nama_file as pathfiles,grup FROM download2 where grup='xxx'";
}
$stmt = $conn->prepare($sql);
$stmt->execute();
//CHECK WHETHER THERE IS ANY POST IN OUR DATABASE
if($stmt->rowCount() > 0){
// CREATE POSTS ARRAY
$posts_array = [];
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
$post_data = [
'id' => $row['id_download'],
'judul' => $row['judul'],
'pathfiles' => "<a href='downlot.php?file='".$row['pathfiles']."'></a>" ,
'jenislaporan' => $row['grup']
];
// PUSH POST DATA IN OUR $posts_array ARRAY
array_push($posts_array, $post_data);
}
//SHOW POST/POSTS IN JSON FORMAT
echo json_encode($posts_array);
}
else{
//IF THER IS NO POST IN OUR DATABASE
echo json_encode(['message'=>'No post found']);
}
?>