我真的很努力处理这段 pf php 代码,我想使用从另一个表中获取的数据将一条消息插入到一个表中。这是我拥有的代码:
$get_user_sql = "SELECT username FROM members WHERE id = '$member'";
$get_user_res = mysqli_query($con, $get_user_sql);
while($username = mysqli_fetch_assoc($get_user_res)){
$user = $username["username"];
};
$get_message_sql = "SELECT message FROM posts WHERE id = '1377077348-5922'";
$get_message_res = mysqli_query($con, $get_message_sql);
while($postsmessage = mysqli_fetch_assoc($get_message_res)){
$postmessage = $postsmessage["message"];
};
$type = "liked";
$title = "New Like";
$message = "<a href=\"profile.php?member=$user\">$user</a> just liked your post:<br /><i>$postmessage</i>";
$insert_note_sql = "INSERT INTO notes (id, sender, recipient, type, title, message, date) VALUES('$id', '$member', '$recipient', '$type', '$title', '$message', '$time')";
$insert_note_res = mysqli_query($con, $insert_note_sql);
我发现如果我从 $message 行中删除 $postmessage 一切正常,但是当我再次添加它时,不会插入该行。任何人都可以看到这样做的原因吗?