<?php
include "db.php";

header("Content-Type: application/json");

$data=[];

$q=mysqli_query($conn,"SELECT * FROM media ORDER BY id DESC");

if($q){
while($r=mysqli_fetch_assoc($q)){
$data[]=$r;
}
}

echo json_encode($data);
?>