2 人のユーザー間の会話を表示しようとしています。メッセージを表示する view.php があり、そのページに返信ボタンもあります。データを既存のメッセージ行に挿入し、すべての会話を表示する方法がわかりません。助けてくれてありがとう。
私のテーブル構造:
id
from_user
to_user
deleted
message
date
view.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();
}