我目前仍在学习PHP,我已经在这个项目上工作了一个多星期。我把头发拉了出来。因此,我们有一个潜在客户管理系统,用户可以为分配给他们的潜在客户输入评论。如果潜在客户被丢弃或分配给其他用户,我们希望隐藏这些评论。
以下是当前代码:
<?php $lead_id = $row['id'];?>
<?php $getcommentscount_stmt = "SELECT COUNT(*) FROM comments WHERE comment_by_user_id = $_SESSION[user_id] AND lead_id = $lead_id ORDER BY comment_created_on DESC";?>
<?php $result_commentscount = mysqli_query($mysqli, $getcommentscount_stmt);?>
<?php $comment_count = mysqli_fetch_row($result_commentscount);?>
<?php $num_comments = $comment_count[0];?>
<div class="panel-group" id="accordion2" style="margin-bottom: 0px;">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo<?php echo $row['id'];?>">Comments<span class="caret"></span> <span class="badge pull-right"><?php echo $num_comments;?></span></a>
</h4>
</div>
<div id="collapseTwo<?php echo $row['id'];?>" class="panel-collapse collapse">
<div class="panel-body">
<table class="table table-bordered">
<tr>
<td width="25%"><strong>Time</strong></td>
<td width="75%"><strong>Comment</strong></td>
</tr>
<?php $lead_id = $row['id'];?>
<?php $getcomments_stmt = "SELECT * FROM comments WHERE comment_by_user_id = $_SESSION[user_id] AND lead_id = $lead_id ORDER BY comment_created_on DESC";?>
<?php $result_comments = mysqli_query($mysqli, $getcomments_stmt);?>
<?php while($row2 = mysqli_fetch_array($result_comments)) { ?>
<tr>
<td width="25%"><?php echo $row2['comment_created_on'];?></td>
<td width="75%"><?php echo nl2br($row2['comment_text']);?></td>
</tr>
<?php } ?>
</table>
这是我尝试的最后一件事:
<?php $getcomments_stmt = "SELECT * FROM comments WHERE comment_by_user_id = $_SESSION[user_id] AND lead_id = $lead_id AND times_assigned <> 1 OR times_assigned IS NULL ORDER BY comment_created_on DESC";?>
我不确定还能展示什么,但感谢任何帮助。
编辑:我收到了这个
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /var/www/html/html/showleads.html on line 884
第884行:
<?php while($row2 = mysqli_fetch_array($result_comments)) { ?>