-
Notifications
You must be signed in to change notification settings - Fork 1
/
rec_artist.php
82 lines (61 loc) · 1.78 KB
/
rec_artist.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<head>
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/font-awesome.css">
<script src="js/jquery.js"></script>
<script src="js/bootstrap.js"></script>
</head>
<h2>Recommended artists</h2>
<?php
//$user=$_SESSION["email"];
include("dbconfig.php");
/*$u="SELECT * FROM user_details WHERE `email`='$user' ";
$r=mysqli_query($con,$u);
$row=mysqli_fetch_array($r,MYSQLI_ASSOC);
$uid=$row["uid"];
//echo $name;
*/
$uid=2;
?>
<?php
$sql="SELECT Count(*) FROM `liked_album`";
$res=mysqli_query($con,$sql);
$r=mysqli_num_rows($res);
if($r==0)
{
// display top artists
echo "<script src='top_tracks.js'></script>";
echo "<div class='row' id='top_tra'> </div><hr>";
}
else
{
if($r>4)
{
$r=4;
}
$sql="SELECT * FROM `liked_album` WHERE `uid`='$uid' LIMIT $r ";
$t=mysqli_query($con,$sql);
echo mysqli_error($con);
while($row=mysqli_fetch_array($t,MYSQLI_ASSOC))
{
$art_name=$row["art_name"];
//echo $art_name;
echo "<input type='hidden' value=".$art_name." id='get_ele'/>";
echo "<script>
$(document).ready(function() { var variable=document.getElementById('get_ele').value;
console.log(variable);
$.getJSON(\"http://ws.audioscrobbler.com/2.0/?method=artist.getsimilar&artist=\"+variable+\"&api_key=4a9f5581a9cdf20a699f540ac52a95c9&limit=4&format=json&callback=?\", function(json) {
var html = '';
var str='';
var sln = 0;
$.each(json.similarartists.artist, function(i, item) {
str=JSON.stringify(item.image[2]);
var sln = str.length;
str=str.slice(10,sln-17);
html += \"<img src=\"+str+\" alt='aa' style='border-radius:20%;width:8%'><a href=\"+item.url+\" style='font-size:20px;margin-left:150px;'>\"+item.name+\"</a><hr>\";
$('#top_art').append(html);
});
});
});
</script>";
}}
?>