-
Notifications
You must be signed in to change notification settings - Fork 1
/
add_playlist.php
47 lines (35 loc) · 1.19 KB
/
add_playlist.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
<?php
$playlist=$_GET['playlist'];
$song_name=$_GET['song_name'];
include('dbconfig.php');
//get uid
$user=$_SESSION["email"];
$u="SELECT * FROM user_details WHERE `email`='$user' ";
$r=mysqli_query($con,$u);
$row=mysqli_fetch_assoc($r);
$uid=$row["uid"];
// if playlist of the user already included add to that playlist otherwise create a new one
$sql="SELECT * FROM playlist_user WHERE playlist_name='$playlist' AND uid='$uid' ";
$r=mysqli_query($con,$sql);
if(mysqli_num_rows($con)>0)
{
//get pid
$sql="SELECT * FROM playlist_user WHERE playlist_name='$playlist' AND uid='$uid' ";
$r=mysqli_query($con,$sql);
$row=mysqli_fetch_array($r,MYSQLI_ASSOC);
$pid=$row["p_id"];
$sql="INSERT INTO playlist_song(`pid`,`song_name`) VALUES('$pid','$song_name') ";
$r=mysqli_query($con,$sql);
}
else
{
$sql="INSERT INTO playlist_user(`playlist_name`,`uid`) VALUES('$playlist','$uid') ";
$r=mysqli_query($con,$sql);
$sql="SELECT * FROM playlist_user WHERE playlist_name='$playlist' AND uid='$uid' ";
$r=mysqli_query($con,$sql);
$row=mysqli_fetch_array($r,MYSQLI_ASSOC);
$pid=$row["p_id"];
$sql="INSERT INTO playlist_song(`pid`,`song_name`) VALUES('$pid','$song_name') ";
$r=mysqli_query($con,$sql);
}
?>