-
Notifications
You must be signed in to change notification settings - Fork 0
/
like.php
41 lines (40 loc) · 1.14 KB
/
like.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
<?php
session_start();
include_once("abcd.php");
$ID=$_SESSION['ID'];
date_default_timezone_set("Asia/Calcutta");
if($_POST['a']==0){
$currenttime=date("Y-m-d H:i");
$queryt="UPDATE profiles SET lastonline='$currenttime' WHERE ID='$ID' ";
$runt=mysqli_query($con,$queryt);
}
else{
$postID=$_POST['a'];
$query="SELECT likedBy,likes FROM feeds WHERE postID='$postID' ";
$run=mysqli_query($con,$query);
$data=mysqli_fetch_assoc($run);
$count=0;
if($data!=NULL){
$arr=explode('-',$data['likedBy']);
foreach($arr as $xID){
if($xID==$ID){
$count++;
}
}
if($count==0){
if(strlen($data['likedBy'])==0){
$likedBy=$ID;
}
else{
$likedBy=$data['likedBy'].'-'.$ID;}
$likes=$data['likes']+1;
$queryl="UPDATE feeds SET likedBy='$likedBy',likes='$likes' WHERE postID='$postID' ";
$runl=mysqli_query($con,$queryl);
echo $likes.'❤';
}
else{
echo $data['likes'].'❤';
}
}
}
?>