Php 一个问题是,当我们无法打开一个新的聊天室时,我们应该如何聊天?你可以使用评论,直到mod创建一个如上所述的聊天室。然后,所有人都可以使用新创建的房间。会议室达到目的后,尝试使用聊天室中讨论的其他细节更新问题/答案,然后将评论标记为“不再需要”。@Jonat
Php 一个问题是,当我们无法打开一个新的聊天室时,我们应该如何聊天?你可以使用评论,直到mod创建一个如上所述的聊天室。然后,所有人都可以使用新创建的房间。会议室达到目的后,尝试使用聊天室中讨论的其他细节更新问题/答案,然后将评论标记为“不再需要”。@Jonat,php,session,mysqli,Php,Session,Mysqli,一个问题是,当我们无法打开一个新的聊天室时,我们应该如何聊天?你可以使用评论,直到mod创建一个如上所述的聊天室。然后,所有人都可以使用新创建的房间。会议室达到目的后,尝试使用聊天室中讨论的其他细节更新问题/答案,然后将评论标记为“不再需要”。@Jonathan Thunberg你能帮我吗?我的评论不适用于扩展讨论;这个对话已经结束。@SamuelLiew只是一个问题,当我们无法打开一个新的聊天室时,我们应该如何聊天?你可以使用评论,直到mod创建了一个如上所述的聊天室。然后,所有人都可以使用新
一个问题是,当我们无法打开一个新的聊天室时,我们应该如何聊天?你可以使用评论,直到mod创建一个如上所述的聊天室。然后,所有人都可以使用新创建的房间。会议室达到目的后,尝试使用聊天室中讨论的其他细节更新问题/答案,然后将评论标记为“不再需要”。@Jonathan Thunberg你能帮我吗?我的评论不适用于扩展讨论;这个对话已经结束。@SamuelLiew只是一个问题,当我们无法打开一个新的聊天室时,我们应该如何聊天?你可以使用评论,直到mod创建了一个如上所述的聊天室。然后,所有人都可以使用新创建的房间。一旦聊天室达到了目的,尝试使用聊天室中讨论的其他细节更新问题/答案,然后将评论标记为“不再需要”。@Jonathan Thunberg你能帮我吗
id from_id from_name to_id to_name msg sent_date
1 2 john 3 master hi how are you? 2019-12-05 04:14:20
2 3 master 2 john fine 2019-12-05 05:15:58
3 2 john 3 master hi 2019-12-05 03:20:34
4 5 previn 2 john hi 2019-12-05 08:30:40
userid | username | profile_pic
<a href="cons.php?to_id=<?php echo $guaranteed_from_id ?>&to_name=<?php echo $row['from_name'];?>">Replay</a>
<?php
if (isset($_SESSION['userid'])) {
$session_id = $_SESSION['userid'];
}
if ($stmt = $con->prepare("SELECT * FROM pm WHERE from_id = ? OR to_id = ? ORDER BY sent_time DESC")) {
$stmt->bind_param('ii', $session_id, $session_id);
$stmt->execute();
}
$tempArray = array();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
if (!in_array($row['to_id'].$row['from_id'], $tempArray)) {
echo "<br>";
echo $row['from_id']." - " . $row['to_id']." ". $row['msg']. " - " .$row['sent_time'];
$guaranteed_from_id = str_replace($session_id, null, $row['to_id'].$row['from_id']);
?>
<img src="images/<?php echo $row['profile_pic'];?>" height="20px" width="20px"/>
<a href="cons.php?to_id=<?php echo $guaranteed_from_id ?>&to_name=<?php echo $row['from_name'];?>">Replay</a>
<?php
}
array_push($tempArray, $row['from_id'].$row['to_id']);
array_push($tempArray, $row['to_id'].$row['from_id']);
}
} else {
echo "NO MESSAGES";
}
?>
id from_id to_id msg sent_date
1 2 3 hi how are you? 2019-12-05 04:14:20
2 3 2 fine 2019-12-05 05:15:58
3 2 3 hi 2019-12-05 03:20:34
4 5 2 hi 2019-12-05 08:30:40
id username profile_pic
1 john <link to profile picture>
2 master <link to profile picture>
3 john <link to profile picture>
4 previn <link to profile picture>
4 robin <link to profile picture>
if (isset($_SESSION['userid'])) {
$session_id = $_SESSION['userid'];
}
$sql = "SELECT *,
(SELECT username FROM users WHERE userid=from_id) AS from_username,
(SELECT username FROM users WHERE userid=to_id) AS to_username,
(SELECT username FROM users WHERE userid=?) AS my_username,
(SELECT profile_pic FROM users WHERE userid=from_id) AS from_profile_pic,
(SELECT profile_pic FROM users WHERE userid=to_id) AS to_profile_pic,
(SELECT profile_pic FROM users WHERE userid=?) AS my_profile_pic
FROM pm WHERE from_id = ? OR to_id = ? ORDER BY id DESC";
if ($stmt = $con->prepare($sql)) {
$stmt->bind_param('iiii', $session_id, $session_id, $session_id, $session_id);
$stmt->execute();
}
$tempArray = array();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
if (!in_array($row['to_id'].$row['from_id'], $tempArray)) {
$friend_id = str_replace($session_id, null, $row['to_id'].$row['from_id']);
$title = $row['from_username'].$row['to_username'];
$num = strlen($title) ;
$num = $num/2;
$first_half = substr($title,0, $num);
$second_half = substr($title, $num);
if ($first_half == $second_half) {
$friend_username = $row['from_username'];
} else {
$friend_username = str_replace($row['my_username'], null, $row['from_username'].$row['to_username']);
}
$friend_profile_pic = str_replace($row['my_profile_pic'], null, $row['from_profile_pic'].$row['to_profile_pic']);
echo "<br>";
echo $row['from_username'] . " - " . $row['to_username']." ". $row['msg']. " - " .$row['sent_time'];
?>
<img src="images/<?php echo $friend_profile_pic;?>" height="20px" width="20px"/>
<a href="cons.php?to_name=<?php echo $friend_username ?>&to_id=<?php echo $friend_id ?>">Reply</a>
<?php
}
array_push($tempArray, $row['from_id'].$row['to_id']);
array_push($tempArray, $row['to_id'].$row['from_id']);
}
} else {
echo "NO MESSAGES";
}