-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajax_music_like.php
More file actions
51 lines (44 loc) · 1.48 KB
/
ajax_music_like.php
File metadata and controls
51 lines (44 loc) · 1.48 KB
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
<?php
session_start();
include "common.php";
if($_SESSION['ss_id'] == "") {
exit;
}
$user_id = $_SESSION['ss_id'];
$mid = $_REQUEST['mid'];
$uid = $_REQUEST['uid'];
$mode = $_REQUEST['mode'];
if($mode == "like") {
$sql = "select * from musiclike where music_no='$mid' and member_id='$uid'";
$row = dbqueryfetch($sql);
if($row['music_no'] != "") exit;
$sql = "insert into musiclike (music_no, member_id, insdt) values ('$mid', '$uid', now())";
$ret = dbquery($sql);
if($ret) {
$sql2 = "update music set likecount=likecount+1 where no='$mid'";
$ret2 = dbquery($sql2);
if($ret2) {
$sql3 = "select likecount from music where no='$mid'";
$row3 = dbqueryfetch($sql3);
$likecount = $row3['likecount'];
echo $likecount;
}
}
} else if($mode == "unlike") {
$sql = "select * from musiclike where music_no='$mid' and member_id='$uid'";
$row = dbqueryfetch($sql);
if($row['music_no'] == "") exit;
$sql = "delete from musiclike where music_no='$mid' and member_id='$uid'";
$ret = dbquery($sql);
if($ret) {
$sql2 = "update music set likecount=likecount-1 where no='$mid'";
$ret2 = dbquery($sql2);
if($ret2) {
$sql3 = "select likecount from music where no='$mid'";
$row3 = dbqueryfetch($sql3);
$likecount = $row3['likecount'];
echo $likecount;
}
}
}
?>