-
Notifications
You must be signed in to change notification settings - Fork 2
/
api.php
43 lines (33 loc) · 1.05 KB
/
api.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
41
42
<?php
require('conn.php');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: X-Requested-With");
$alisha = [
'albums'=>[],
'artists'=>[]
];
$result = mysqli_query($conn,"SELECT * FROM albums ORDER BY RAND()");
while($row = mysqli_fetch_assoc($result))
{
array_push($alisha['albums'], [
'id'=>$row['id'],
'title'=>$row['title'],
'artist'=>$row['artist'],
'discription'=>$row['discription'],
'artPath'=>$row['artPath'],
'likes'=>$row['likes'],
]);
}
$query = mysqli_query($conn,"SELECT * FROM artists ORDER BY RAND()");
while($r=mysqli_fetch_assoc($query))
{
array_push($alisha['artists'], [
'id'=>$r['id'],
'name'=>$r['name'],
"img"=>$r['imageUrl']
]);
}
header('Content-Type: application/json');
echo json_encode($alisha,JSON_PRETTY_PRINT);
?>