我的回覆只適用於最新/新評論。如果我回復其他評論,它只在文本區域顯示一個空格。如何使用ID顯示評論回覆框
測試案例:如果我在wall.php頁面的末尾替換回復表單,應用css display:block來顯示它,然後點擊父母id的回覆按鈕,然後在寫入任何文本後提交,然後點擊回覆按鈕無法打開它自己的回覆表單。
如何在每頁評論結束時將其替換爲我的回覆表單?
wall.php(當前情況下:如上述鏈接,不能保存的舊評論任何textarea的數據)
script type='text/javascript'>
$(function(){
$("a.reply").click(function() {
var id = $(this).attr("id");
$("#parent_id").attr("value", id);
});
});
</script>
<script>
$('a.reply').livequery("click",function() {
var ID = $(this).attr('id').replace('','');
$("#reply_here-"+ID).slideToggle('slow');
return false;
});
</script>
</head>
global $dbh;
$results = mysqli_query($dbh,"SELECT * FROM comments_lite WHERE qazi_id='$tutid' ORDER BY id DESC LIMIT 5") or die(mysqli_error($dbh));
//find the number of comments
list($commentNum) = mysqli_fetch_array(mysqli_query($dbh,"SELECT COUNT(*) FROM comments_lite WHERE qazi_id='$tutid'"));
echo'<div class="comments"><div id="updates"><div class="content"><comment>';
while($rows = mysqli_fetch_array($results))
{
$id = $rows['id'];
$qazi_id = $rows['qazi_id'];
$likes = $rows['likes'];
$username = $rows['username'];
$img = $rows['img'];
$description = $rows['description'];
$url = $rows['url'];
$parent_id = $rows['parent_id'];
$date = $rows['date'];
echo'<div class="comment">
<div class="cdomment_cheder">';
if ($url=="") {
echo'<p class="name">'.$username.' Says:</p>'; }
else echo'<p class="name"><a href="userinfo.php?user='.$url.'" title="'.$username.'">'.$username.'</a> Says:</p>';
echo'<span class="cdomment_time">'.$date.'</span><br/>
<div class="avatarcnt">
<img alt="" src="uploadprofile/'.$u_imgurl.'"/>
</div></div></div>
<div class="cdomment_text">';
if ($description=="") {echo '';}
else echo''.htmlentities($description).'<br>';
echo '</div>';
//reply
echo'<div class="reply_box"><a href="javascript: void(0)" class="reply" id="'.$id.'">Reply</a></div>';
//Likes
echo'<div></div>';
// Only Reply
$query = "SELECT * FROM comments_reply WHERE parent_id ='".$id."' ORDER BY id DESC";
$res = mysqli_query($dbh,$query);
while($row = mysqli_fetch_array($res)){
$id = $row['id'];
$qazi_id = $row['qazi_id'];
$likes = $row['likes'];
$username = $row['username'];
$img = $row['img'];
$description = $row['description'];
$url = $row['url'];
$parent_id = $row['parent_id'];
$date = $row['date'];
echo' <div class="rcontent"><replycomment><ul>
<div class="comment">
<div class="cdomment_cheder">';
if ($url=="") {
echo'<p class="name">'.$username.' Says:</p>'; }
else echo'<p class="name"><a href="userinfo.php?user='.$url.'" title="'.$username.'">'.$username.'</a> Says:</p>';
echo'<span class="cdomment_time">'.$date.'</span><br/>
<div class="avatarcnt">
<img alt="" src="uploadprofile/'.$u_imgurl.'"/>
</div></div></div>
<div class="cdomment_text">';
if ($description=="") {echo '';}
else echo''.htmlentities($description).'<br>';
echo '</div>';
</ul><replycomment></div>';
} //reply close
?>
// REPLY FORM
<div id="loader"></div><div class="reply_here" id="reply_here-<?php echo $rows['id'] ?>" style="display:none;">
<form action="" method="post" id="repfrm">
<fieldset id="cmntfs">
<legend class="pyct">Your comment</legend>
<input type="hidden" name="username" id="author" value="<?php echo $_SESSION['username'] ?>"/>
<input type="hidden" name="url" id="url" value="" />
<div id="maintbox">
<textarea name="replycom" rows="2" id="replycom"></textarea>
</div>
<input type="hidden" name="parent_id" id="parent_id" value="0" />
<input type="hidden" name="tutid" id="tutid" value="<?php echo $tutid ?>" />
<button type="submit" name="submit" value="" id="submit" class="repfrm">Post Reply</button>
</fieldset>
</form>
</div>
<?
} //comment close
echo'</div><comment></div>';
//pagination
wall.php(TAST情況下:這不能打開每個回覆形式時形式放置在端的頁面)
script type='text/javascript'>
$(function(){
$("a.reply").click(function() {
var id = $(this).attr("id");
$("#parent_id").attr("value", id);
});
});
</script>
<script>
$('a.reply').livequery("click",function() {
var ID = $(this).attr('id').replace('','');
$("#reply_here-"+ID).slideToggle('slow');
return false;
});
</script>
</head>
global $dbh;
$results = mysqli_query($dbh,"SELECT * FROM comments_lite WHERE qazi_id='$tutid' ORDER BY id DESC LIMIT 5") or die(mysqli_error($dbh));
//find the number of comments
list($commentNum) = mysqli_fetch_array(mysqli_query($dbh,"SELECT COUNT(*) FROM comments_lite WHERE qazi_id='$tutid'"));
echo'<div class="comments"><div id="updates"><div class="content"><comment>';
while($rows = mysqli_fetch_array($results)) {
$id = $rows['id'];
$qazi_id = $rows['qazi_id'];
$likes = $rows['likes'];
$username = $rows['username'];
$img = $rows['img'];
$description = $rows['description'];
$url = $rows['url'];
$parent_id = $rows['parent_id'];
$date = $rows['date'];
echo'<div class="comment">
<div class="cdomment_cheder">';
if ($url=="") {
echo'<p class="name">'.$username.' Says:</p>'; }
else echo'<p class="name"><a href="userinfo.php?user='.$url.'" title="'.$username.'">'.$username.'</a> Says:</p>';
echo'<span class="cdomment_time">'.$date.'</span><br/>
<div class="avatarcnt">
<img alt="" src="uploadprofile/'.$u_imgurl.'"/>
</div></div></div>
<div class="cdomment_text">';
if ($description=="") {echo '';}
else echo''.htmlentities($description).'<br>';
echo '</div>';
//reply
echo'<div class="reply_box"><a href="javascript: void(0)" class="reply" id="'.$id.'">Reply</a></div>';
//Likes
echo'<div></div>';
// Only Reply
$query = "SELECT * FROM comments_reply WHERE parent_id ='".$id."' ORDER BY id DESC";
$res = mysqli_query($dbh,$query);
while($row = mysqli_fetch_array($res)){
$id = $row['id'];
$qazi_id = $row['qazi_id'];
$likes = $row['likes'];
$username = $row['username'];
$img = $row['img'];
$description = $row['description'];
$url = $row['url'];
$parent_id = $row['parent_id'];
$date = $row['date'];
echo' <div class="rcontent"><replycomment><ul>
<div class="comment">
<div class="cdomment_cheder">';
if ($url=="") {
echo'<p class="name">'.$username.' Says:</p>'; }
else echo'<p class="name"><a href="userinfo.php?user='.$url.'" title="'.$username.'">'.$username.'</a> Says:</p>';
echo'<span class="cdomment_time">'.$date.'</span><br/>
<div class="avatarcnt">
<img alt="" src="uploadprofile/'.$u_imgurl.'"/>
</div></div></div>
<div class="cdomment_text">';
if ($description=="") {echo '';}
else echo''.htmlentities($description).'<br>';
echo '</div>';
</ul><replycomment></div>';
} //reply close
} //comment close
?>
// REPLY FORM
<div id="loader"></div><div class="reply_here" id="reply_here-<?php echo $rows['id'] ?>" style="display:block;">
<form action="" method="post" id="repfrm">
<fieldset id="cmntfs">
<legend class="pyct">Your comment</legend>
<input type="hidden" name="username" id="author" value="<?php echo $_SESSION['username'] ?>"/>
<input type="hidden" name="url" id="url" value="" />
<div id="maintbox">
<textarea name="replycom" rows="2" id="replycom"></textarea>
</div>
<input type="hidden" name="parent_id" id="parent_id" value="0" />
<input type="hidden" name="tutid" id="tutid" value="<?php echo $tutid ?>" />
<button type="submit" name="submit" value="" id="submit" class="repfrm">Post Reply</button>
</fieldset>
</form>
</div>
<?
echo'</div><comment></div>';
//pagination
謝謝無用的命令,沒有你沒有人可以幫助或指導我。 5天,我試圖解決它。但我不明白你的解決方案。怎麼做?給我更多先生。 – joy 2014-11-24 16:01:36
先生我的每一個表格都用自己的id滑動,還保存用戶名和父母id等,但不能只保存textarea的文本。 – joy 2014-11-24 16:11:13
是的,它有一個ID,但它的ID相同,至少在http://bdshowbiz.com/loginfinal/demo.php。我檢查了螢火蟲。 – 2014-11-24 16:15:43