특정 그룹에서 추천수 많은 글 추출 하는건데.. > 그누3질답

그누3질답

특정 그룹에서 추천수 많은 글 추출 하는건데.. 정보

그누보드 특정 그룹에서 추천수 많은 글 추출 하는건데..

본문

특정 그룹에서 추천수 많은 글 추출 하는건데..
여기 저기 팁에서...막 끼어 넣은 겁니다...
아직 초보 인지라...
근데 되긴 되더라구요....신기 해서리...^^;;;;;
맞는건지..??
root 님께서 말씀하신 소스에서..
여기 저기 팁란 읽으면서..
sql문만..바꺼끼었습니다..

고수분들..코드 정리 부탁 드리겟습니다..


<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가

define("_DOCTYPE_", "NONE");



$maxrow = 10; // default 조회 값

?>

<table width=95% cellpadding=3 cellspacing=0 align=center>
<tr><td height=1 background='./<?=$cfg[bbs_dir]?>/line.gif'></td></tr>
<tr><td &nbsp;class='subject subjectbg ht'> <?=$html_title?></td></tr>
<tr><td height=1 background='./<?=$cfg[bbs_dir]?>/line.gif'></td></tr>
</table>
<p>

<table width=95% cellpadding=0 cellspacing=0 align=center>
<tr>
 &nbsp; <td width='' valign=top>

<?
$sql = " select a.bo_subject, a.bo_table, b.gr_subject
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;from $cfg[table_board] a, $cfg[table_group] b
 &nbsp; &nbsp; &nbsp; &nbsp; where a.gr_id = b.gr_id AND b.gr_id = '그룹명'
 &nbsp; &nbsp; &nbsp; &nbsp; order by b.gr_id, a.bo_table ";

$result = sql_query($sql);

while ($row = mysql_fetch_array($result)) {
 &nbsp; $tbl = "{$cfg[write_table_prefix]}{$row[bo_table]}";

 &nbsp; $sql2 = " select wr_id,
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wr_parent_id,
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mb_id,
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wr_name,
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wr_email,
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wr_homepage,
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wr_num,
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wr_subject,
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wr_comment,
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wr_commentcnt,
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wr_datetime,
wr_good,
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wr_hit
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; from $tbl
where wr_comment = '0'
order by wr_good desc
limit 0, $maxrow";

 &nbsp;
 &nbsp; $result2 = sql_query($sql2);
 &nbsp; for ($i = 0; $row2 = mysql_fetch_array($result2); $i++) {
 &nbsp; &nbsp; &nbsp; $wr_subject = get_text($row2[wr_subject]);

 &nbsp; &nbsp; &nbsp; $key = $row2[wr_good] . $row2[wr_datetime];

 &nbsp; &nbsp; &nbsp; $list[$key]->bo_subject = $row[bo_subject];
 &nbsp; &nbsp; &nbsp; $list[$key]->bo_table = $row[bo_table];
 &nbsp; &nbsp; &nbsp; $list[$key]->mb_id = $row2[mb_id];
 &nbsp; &nbsp; &nbsp; $list[$key]->mb_open = $row2[mb_open];
 &nbsp; &nbsp; &nbsp; $list[$key]->wr_id = $row2[wr_id];
 &nbsp; &nbsp; &nbsp; $list[$key]->wr_parent_id = $row2[wr_parent_id];
 &nbsp; &nbsp; &nbsp; $list[$key]->wr_email = $row2[wr_email];
 &nbsp; &nbsp; &nbsp; $list[$key]->wr_homepage = $row2[wr_homepage];
 &nbsp; &nbsp; &nbsp; $list[$key]->wr_name = get_text(cut_str($row2[wr_name],12));
 &nbsp; &nbsp; &nbsp; $list[$key]->wr_subject = get_text(cut_str($wr_subject,70,'…'));
 &nbsp; &nbsp; &nbsp; $list[$key]->wr_comment = $row2[wr_comment];
 &nbsp; &nbsp; &nbsp; $list[$key]->wr_commentcnt = $row2[wr_commentcnt];
 &nbsp; &nbsp; &nbsp; $list[$key]->wr_datetime = $row2[wr_datetime];
 &nbsp; &nbsp; &nbsp; $list[$key]->wr_good = $row2[wr_good];
 &nbsp; }
 &nbsp; mysql_free_result($result2);
}
mysql_free_result($result);

?>

<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr><td colspan=4 height=1 background='./<?=$cfg[bbs_dir]?>/line.gif'></td></tr>
<tr class='subject subjectbg ht' align="center">
 &nbsp; <!--
 &nbsp; <td><?=subject_sort_link('bo_table', $qstr2)?>게시판</td>
 &nbsp; <td><?=subject_sort_link('bo_subject', $qstr2)?>제목</td>
 &nbsp; <td><?=subject_sort_link('wr_name', $qstr2)?>작성자</td>
 &nbsp; <td><?=subject_sort_link('wr_hit', $qstr2)?>조회수</td>
 &nbsp; -->
 &nbsp; <td>게시판</td>
 &nbsp; <td>제목</td>
 &nbsp; <td>작성자</td>
 &nbsp; <td>추천수</td>
</tr>
<tr><td colspan=4 height=1 background='./<?=$cfg[bbs_dir]?>/line.gif'></td></tr>
<?
if (count($list) > 0) {
 &nbsp; $i=0;

 &nbsp; krsort($list,1);
 &nbsp; reset ($list);

 &nbsp; foreach ($list as $key=>$value) {
 &nbsp; &nbsp; &nbsp; if ($i >= $maxrow) break;
 &nbsp; &nbsp; &nbsp; $comment = "";
 &nbsp; &nbsp; &nbsp; $atag_comment = "";
 &nbsp; &nbsp; &nbsp; if ($value->wr_comment > 0) {
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $comment = "<span style='font-size:8pt;'>[c]</span> ";
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $atag_comment = "#c{$value->wr_id}";
 &nbsp; &nbsp; &nbsp; }

 &nbsp; &nbsp; &nbsp; $commentcnt = "";
 &nbsp; &nbsp; &nbsp; if ($value->wr_commentcnt > 0) {
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $commentcnt = "<font size=-2>({$value->wr_commentcnt})</font>";
 &nbsp; &nbsp; &nbsp; }

 &nbsp; &nbsp; &nbsp; $name = gblayer($value->mb_id, cut_str($value->wr_name,12), $value->wr_email, $value->wr_homepage);

 &nbsp; &nbsp; &nbsp; $value->bo_subject = cut_str($value->bo_subject, 20);

 &nbsp; &nbsp; &nbsp; $list = $i++%2;

 &nbsp; &nbsp; &nbsp; echo "<tr class='list$list ht' align=center>";
 &nbsp; &nbsp; &nbsp; echo "<td width=150><a href='./?doc=$cfg[bbs_dir]/gnuboard.php&bo_table=".$value->bo_table."'>".$value->bo_subject."</a></td>";
 &nbsp; &nbsp; &nbsp; echo "<td align=left> &nbsp;<a href='./?doc=$cfg[bbs_dir]/gnuboard.php&bo_table=".$value->bo_table."&wr_id=".$value->wr_parent_id."$atag_comment'>$comment{$value->wr_subject}</a> {$commentcnt}</td>";
 &nbsp; &nbsp; &nbsp; echo "<td width=120> $name </td>";
 &nbsp; &nbsp; &nbsp; //echo "<td width=110 align=center>[".substr($value->wr_datetime,2,14)."]</td>";
 &nbsp; &nbsp; &nbsp; echo "<td width=60>{$value->wr_good}</td>";
 &nbsp; &nbsp; &nbsp; echo "</tr>\n";

 &nbsp; &nbsp; &nbsp; //echo "<tr><td colspan=4 background='{$gnu_path}image/line_width.gif'></td></tr>\n";
 &nbsp; }

} else
 &nbsp; echo "<td height=100 align=center colspan=4>등록된 글이 없습니다.</td>";
?>
<tr><td colspan=4 height=1 background='./<?=$cfg[bbs_dir]?>/line.gif'></td></tr>
</table>

<p>
 
</td>
</tr>
</table>
  • 복사

댓글 전체

멋지게 잘하셨군요. 따로 더 정리할것도 없을것 같습니다.
테이블 조회에서 원하는 그룹을 설정하고,  테이블 내용조회중에 추천이 많은 것을 조회하도록 설정한것이라는 설명만으로 더이상 할것이 없을듯 하군요.
조금더 손을 본다면 타이틀(게시판) 클릭시 정렬을 할수있는 기능을 부여하면 더 좋을듯 하군요.
이대로 팁앤테크에 올리셔도 많은 분들이 사용가능할것 같습니다.
© SIRSOFT
현재 페이지 제일 처음으로