<?php
 
include 'dataconfig.php' ;

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}


$sql = "SELECT * FROM `music` ORDER BY id DESC";

$result = $conn->query($sql);

mysqli_query($conn,$sql); 

$response = array();

while($row = mysqli_fetch_array($result)){
    array_push($response,array(
        'id'=>$row['id'],
        'title'=>$row['title'],
        'album'=>$row['album'],
        'artist'=>$row['artist'],
        'producer'=>$row['producer'],
        'path'=>$row['path'],
        'image'=>$row['image'],
        'like'=>$row['like'],
        'dislike'=>$row['dislike'],
        'listens'=>$row['listens'],
        'price'=>$row['price'],
        'pesa'=>$row['pesa'],
        'discount'=>$row['discount'],
        'genre'=>$row['genre']
    ));
}
echo json_encode(array('result'=>$response));
$conn->close();
?>