【发布时间】:2020-04-01 09:42:14
【问题描述】:
我正在 PHP mysqli 中创建两个用户对话视图脚本。我的脚本如果其他用户的最后一条消息它的 URL 打开,但是当我作为最后一条消息发送时,它没有打开,因为它显示了我的 id,因此 我想在没有我的 id 的情况下获取另一个用户 id 到 URL,
对不起,我的英语不好。
我的数据库下午表
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
网址
<a href="cons.php?to_id=<?php echo $row['from_id'];?">Replay</a>
这是我的源代码
<?php
require_once"config.php";
if (isset($_SESSION['userid'])) {
$to_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', $to_id, $to_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'];
?>
<a href="cons.php?to_id=<?php echo $row['from_id'];?">Replay</a>
<?php }?>
<?php
array_push($tempArray, $row['from_id'].$row['to_id']);
array_push($tempArray, $row['to_id'].$row['from_id']);
}
} else {
echo "NO MESSAGES";
}
?>
【问题讨论】:
-
无法理解 ;)。你想在这里说什么
-
你可以用印地语或英式英语告诉我你的观点。
-
你想在href中获取谁的ID?
-
当我讨论另一个用户的最后一条消息时,如果已发送,我无法打开覆盖,因为它显示了我的 ID,因此我想让另一个用户将其发送到 url
-
当我发送最后一条消息时我的问题没有打开,但是如果发送给我的最后一条消息它的 url 打开另一个用户。