大家好,我想要一个 div,它位于 php 的 while 循环中,当单击一个按钮时,它会被切换。单击特定按钮时,应切换特定的 div。到目前为止,我已经尝试过并且它有效,但仅适用于循环的第一个 div。只有第一个 div 被切换,请帮忙。
Show comments 是要点击的按钮:
<td colspan=2 style="background-color:#FFFBE6;opacity:.89;height:25px;max-height:27px;">
<div style="float:left;margin-left:80px;" id="ratinginadiv">
<b class="ratings" id="showcomm" onclick="showcomments(this);"><?=$no_ofcomments?> comments |</b> <b class="ratings"><?=$no_offollowers?> Following </b> |
<b onclick="displaystars();" class="ratings">Star</b>|</div></td>
div id="commentdiv">
<table style="background-color:#DDFFFF; border:1px solid #C9D291;width:100%;margin-bottom:0px;border-top:0px;margin-top:0px;" align="center" cellspacing=0>
<?php
$onid=$postainarray['id'];
$selectcomments=mysql_query("select comments,time,onemail,emailid ,hidden from waf where onid_comment='$onid' and comments!='' ");
while($commentsinaray=mysql_fetch_array($selectcomments)){
$commemail=$commentsinaray['emailid'];
$dataofcommenter=mysql_query("select name,pic,email,dob,gender from fk_mem where email='$commemail'");
$datainarray=mysql_fetch_array($dataofcommenter);
if($commentsinaray['hidden'] == 'hide'){
$nameintitle='hidden';
$emailintitle='hidden';
$picofcomm="blur.jpg";
}
else{
$nameintitle=$datainarray['name'];
$emailintitle=$datainarray['email'];
$picofcomm=$datainarray['pic'];
}
?>
<tr>
<td align="center" style="width:55px;background-color:white;opacity:1;border-bottom:2px solid white;">
<a title="<?=$nameintitle?>,<?=$datainarray['gender']?>,[<?=$datainarray['dob']?>],<?=$emailintitle?>" href="profile_page_name.php?friendemail=<?=$emailintitle?>"><img src="uploads/<?=$picofcomm?>" style="width:40px;max-height:55px; border:1px solid green;padding:1px;" /></a>
</td>
<td align="left" style="background-color:#F3FCFF;opacity:1;border-bottom:2px solid white;">
<a href="profile_page_name.php?friendemail=<?=$emailintitle?>" title="Go to <?=$nameintitle?>'s Profile.." style="text-decoration:none;color:#718E99;font-weight:normal;margin-left:5px;margin-bottom:0px;">
<?=$nameintitle?></a><br>
<p style="margin-left:5px;margin-top:0px;"><?=$commentsinaray['comments']?></p>
</td>
<td align="left" style="width:65px;vertical-align:top;border-left:2px solid white;border-bottom:2px solid white;">
<small style="color:red;font-size:14px;"><?=$commentsinaray['time']?></small>
</td>
</tr>
<?php } ?>
<tr>
</table>
</div>
function showcomments(obj){
var currentdiv = $("#commentdiv");
currentdiv.slideToggle();
}