get.php
822 Bytes
<?php
include_once("config.php");
$item = array();
if(isset($_POST['id'])){
$query = mysqli_query($mysqli,"select * from songs where id = '".$_POST['id']."'");
$i = 0;
while($row = mysqli_fetch_assoc($query)){
$item['id'] = $row['id'];
$item['song'] = $row['song_name'];
$item['singer'] = $row['artist_name'];
$item['image'] = $row['song_img'];
$item['positive_rating'] = $row['rating_no'];
}
}else
{
$query = mysqli_query($mysqli,"select * from songs");
$i = 0;
while($row = mysqli_fetch_assoc($query)){
$item[$i]['id'] = $row['id'];
$item[$i]['song'] = $row['song_name'];
$item[$i]['singer'] = $row['artist_name'];
$item[$i]['image'] = $row['song_img'];
$item[$i]['positive_rating'] = $row['rating_no'];
$i++;
}
}
echo(json_encode($item));
?>