我正在将一个系统放在一起,我希望获得不包含session['id']
用户的用户行数,这样我就可以显示有点像facebook的链接。
示例:You and x.. others likes this
显然,只使用标准num行抓取数据库中的所有记录,但我想排除会话。
$likes = mysqli_query($mysqli, "
SELECT feedback_streamid,feedback_userid,feedback_rating FROM streamdata_feedback
WHERE feedback_streamid=".$streamitem_data['streamitem_id']."
AND feedback_rating=1 ORDER BY feedback_id LIMIT 10")
or die("SELECT Error: ".mysqli_error($mysqli));
$numRowslikes = mysqli_num_rows($likes);
while ($row = mysqli_fetch_array($likes)) {
$likesmemberid = rawfeeds_user_core::getuser($row['feedback_userid']);
$user1_id = $_SESSION['id'];
$user2_id = $row['feedback_userid'];
if ($user2_id == $_SESSION['id']) {
echo '<div class="like_name"><b><a href="profile.php?username='.$likesmemberid['username'].'">You and</a> '.$numRowslikes.' Others likes this </b> ';
} else {
echo '<a title="'.$likesmemberid['fullname'].' Likes This" href="profile.php?username='.$likesmemberid['username'].'"> <img border=\'0\' src=\'../userimages/ cropped'.$row['feedback_userid'].'.jpg\' onerror="this.src=\'userimages/no_profile_img.jpeg\'" width=\'20\' ></a> ';
}
}
答案 0 :(得分:0)
听起来您可以更改查询以排除当前用户的ID,然后正常使用num_rows()。
WHERE feedback_userid NOT IN ('whatever_id_here')