我发布了两件事。该评论可以正常工作,但我需要发布的第二项$list['id']
是每一行独有的。当用户单击 POST 时,如何包含此唯一 ID,以便可以在发布它的页面上使用它。
foreach ($posts as $key => $list){
echo " <tr valign='top'>\n";
echo " <tr>$list['id']
<div class='comment_text'>
<form method='post' action='add_comment.php'>
<textarea name='comment'</textarea>
<input class='btn' type='submit' value='Post'/>
</form>
</div>
</td>\n";
echo "</tr>\n";
}
我发布到的页面如下所示:
<?php
$commenter_user_id = $_SESSION['user_id'];
$body = substr($_POST['comment'],0,400);
$post_id=;
add_comment($commenter_user_id,$post_id,$body);
$_SESSION['message'] = "Your comment has been added!";
header("Location:/social_learning/site_pages/profile.php");
?>