-
Notifications
You must be signed in to change notification settings - Fork 1
/
view_messages.php
52 lines (43 loc) · 2.07 KB
/
view_messages.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
<?php
session_start();
include('dbconfig.php');
$selfID = $_SESSION['id'];
function following_check($conn, $id_followed){
$selfID = $_SESSION['id'];
$result = mysqli_query($conn, "SELECT * FROM followerData WHERE userID = $id_followed AND followerID = $selfID");
return ($result->num_rows > 0) ? TRUE : FALSE ;
}
$fetch_messages = mysqli_query($conn, "SELECT * FROM `publicMessageData` ORDER BY posting_time DESC");
while($read_msg = $fetch_messages->fetch_assoc()){
$test_id = $read_msg['from_ID'];
$self_ID = $_SESSION['id'];
if($test_id == $self_ID){
$fetch_name_dp = mysqli_query($conn, "SELECT name, img from userData where userID = $test_id");
while($dp = $fetch_name_dp->fetch_assoc()){
$target_dp = $dp['img'];
$target_name = $dp['name'];
}
echo "<tr><td><img src = ";
if(isset($target_dp)){
echo "'userImages/".$target_dp."'";
}
else{ echo "'res/default.jpeg'";}
echo "style = 'border-radius: 50%' width = 50px height = 50px></td>";
echo "<td>You : </td><td>".$read_msg['message']."</td><td>".$read_msg['posting_time']."</td>";
}
if(following_check($conn, $test_id)){
$fetch_name_dp = mysqli_query($conn, "SELECT name, img from userData where userID = $test_id");
while($dp = $fetch_name_dp->fetch_assoc()){
$target_dp = $dp['img'];
$target_name = $dp['name'];
}
echo "<tr><td><img src = ";
if(isset($target_dp)){
echo "'userImages/".$target_dp."'";
}
else{ echo "'res/default.jpeg'";}
echo "style = 'border-radius: 50%' width = 50px height = 50px></td>";
echo "<td>".$target_name." : </td><td>".$read_msg['message']."</td><td>".$read_msg['posting_time']."</td>";
}
}
?>