我正在尝试显示两个用户之间的对话,并且我有 view.php 来显示消息,并且该页面上还有回复按钮。我不知道如何将数据插入现有的消息行并显示所有对话。谢谢你的帮助。
我的表结构:
id
from_user
to_user
deleted
message
date
视图.php
$user = 'currentuser';
$reply = $_POST['relpy'];
$id = $_GET['id'];
if (isset($_POST['replyto']))
$reply = $_POST['reply']; {
if(!empty($reply)){
$mydb = new mysqli('localhost', 'root', '', 'db');//this is where I am stuck I am using update so if I hit reply the existing data in the row will be overwritten.
$stmt = $mydb->prepare("update messages set message = ? where from_user = ? and id = ? ");
echo $mydb->error;
$stmt->bind_param('sss', $reply, $user, $id);
$stmt->execute();
}
}
if(!empty($id)){
$mydb = new mysqli('localhost', 'root', '', 'db');
$stmt = $mydb->prepare("SELECT * FROM messages where from_user = ? and id = ? ");
$stmt->bind_param('ss', $user, $id);
$stmt->execute();
}