추천인 수 구하기 질문드립니다.
본문
추천인 소스는 구했는데 아래 소스에서 전체 추천인 Total을 추가하려는데 잘 않되서 질문드립니다.
<?
if ($mbrecommend == "") { $memberid = $member[mb_id]; } else { $memberid = $mbrecommend; }
$sql = " select
mb_id, mb_name, mb_email, mb_homepage, mb_open, mb_recommend, mb_1 from $g5[member_table]
where mb_recommend = '$memberid' and mb_level >= '2' order by mb_datetime desc ";
$result = sql_query($sql);
if(@sql_num_rows($result)>0) {
echo "<div style='margin:0 0 10 0;'>";
echo "<table width=100% cellpadding=2 cellspacing=1 border=0 bgcolor=#bbbbbb>";
echo "<colgroup><colgroup><colgroup><colgroup><colgroup><colgroup width=50><colgroup width=50>";
echo "<tr bgcolor=#dddddd align=center><td width=5%><td class='small' width=15%>추천코드<td class='small' width=20%>이름";
echo "<td width=15%>가입날짜";
} else {
echo "<div style='margin:0 0 10 0;'>";
echo "<table width=100% cellpadding=2 cellspacing=0 border=0";
echo "<colgroup><colgroup><colgroup><colgroup><colgroup><colgroup width=50><colgroup width=50>";
echo "<tr align=left><td width=100% colspan='4'>추천받은 내역이 없습니다.";
}
if(@sql_num_rows($result)>0) {
for ($i=0,$j=1; $row=sql_fetch_array($result); $i++,$j++) {
$tmp_id = $row[mb_id];
$profile = get_member("$tmp_id");
$sqlRnum = "select count(*) as Rnum from $g5[member_table] where mb_recommend = '$tmp_id' and mb_level >= '2'";
$rowRnum = sql_fetch($sqlRnum);
$name_one = mb_substr($profile[mb_name],0,1,'UTF-8');
echo "<tr bgcolor=#eeeeee align=center>";
echo "<td class='small'>$j";
echo "<td class='small'>$profile[mb_id]";
echo "<td class='small'>$name_one";
echo " * * ";
echo "<td class='small'>$profile[mb_datetime]";
}
}
echo "</table>";
echo "</div>";
?>
답변 2
상단부분에
if ($mbrecommend == "") { $memberid = $member[mb_id]; } else { $memberid = $mbrecommend; }
$sql = " select
mb_id, mb_name, mb_email, mb_homepage, mb_open, mb_recommend, mb_1 from $g5[member_table]
where mb_recommend = '$memberid' and mb_level >= '2' order by mb_datetime desc ";
$result = sql_query($sql);
$re_total_cnt=sql_num_rows($result); // 이부분을 추가 검색한 아이디를 추천한 회원수가 나옵니다
감사합니다.