Php 如何在保留回复的同时移动评论?
我正在尝试创建一个评论系统,用户可以在其中留下评论,然后其他用户可以回复这些评论。我想把实际的帖子放在页面的左侧,评论放在右侧,这样用户就不必滚动浏览实际的帖子来阅读评论。我尝试过使用position:absolute,但这会干扰我的回复系统。有人知道更简单的方法吗 我的代码Php 如何在保留回复的同时移动评论?,php,html,css,Php,Html,Css,我正在尝试创建一个评论系统,用户可以在其中留下评论,然后其他用户可以回复这些评论。我想把实际的帖子放在页面的左侧,评论放在右侧,这样用户就不必滚动浏览实际的帖子来阅读评论。我尝试过使用position:absolute,但这会干扰我的回复系统。有人知道更简单的方法吗 我的代码 while ($commentrow = mysqli_fetch_assoc($commentresult)) { if (mysqli_num_rows($comment
while ($commentrow = mysqli_fetch_assoc($commentresult)) {
if (mysqli_num_rows($commentresult)==0) {
echo '';
}
else {
$commenterid = $commentrow['userid'];
$commentersql = "SELECT * FROM users WHERE userid = '$commenterid'";
$commenterresult = mysqli_query($conn, $commentersql);
while ($commenterrow = mysqli_fetch_assoc($commenterresult)) {
echo '<div class="PostComments">';
if ($commenterrow['profileimg'] == 1) {
$filename = "profilepics/profile".$commenterid."*";
$fileinfo = glob($filename);
$fileext = explode(".", $fileinfo[0]);
$fileactualext = $fileext[1];
echo "<div class='CommentProfilePicture'><img src='profilepics/profile".$commenterid.".".$fileactualext."?".mt_rand()."'></div>";
}
else {
echo "<div class='CommentProfilePicture'><img src='profilepics/noUser.png'></div>";
}
echo "<div class='CommentUserName'>".$commenterrow['userName']."</div>";
echo "<div class='CommenterComment'>".$commentrow['comment']."</div> </div>";
}
$currentcommentid = $commentrow['commentid'];
$replysql = "SELECT * FROM posts WHERE hostid = '$hostid' AND postid = '$postid' AND commentid = '$currentcommentid' AND replyid > 0";
$replyresult = mysqli_query($conn, $replysql);
while ($replyrow = mysqli_fetch_assoc($replyresult)) {
if (mysqli_num_rows($replyresult)==0) {
echo '';
}
else {
echo '
<div class="PostReplies">
<p>
'.$replyrow['reply'].'
</p>
</div>
';
}
}
}
}
如果您有任何问题,我将非常乐意回答。在评论和回复上创建div标记。在评论和回复上创建div标记
.PostPage {
width: 60%;
padding: 10px;
background-color: #555;
color: white;
margin: 0px;
}
.PostComments {
width: 30%;
background-color: #555;
padding: 10px;
border-radius: 4px;
color: white;
}
.PostReplies {
width: 30%;
background-color: #555;
padding: 10px;
color: white;
}