최신글에서 분류별로 select문을 나눠서 보여주는 방법? > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

최신글에서 분류별로 select문을 나눠서 보여주는 방법? 정보

최신글에서 분류별로 select문을 나눠서 보여주는 방법?

본문

스크립터에 능하신 고수분의 도움글을 좀 부탁드리겠습니다.
 
 
 
최신글로 임의의 게시판 제목글을 보여줄때,
'select'문 형식으로 게시물의 제목글을 보여주고 '해당제목글'을 선택하면 1번링크가 작동해서
새창으로 해당 링크화면을 띄워주게끔 되어있습니다.
 
 
[select 형식의 최신글..... 현재 응용 : 사이트 링크용]
---------------------------------------------------------------------
 
<table width='100%' align='center'>
<tr align='center'><td>
<select class='category' name='<?=$list[$i][subject]?>' style='width:130' onchange='gofamily(this.value);'>
<option value=''>== <?=$board[bo_subject]?> ==</option>
<?
for ($i=0; $i<count($list); $i++){
$g4_link    = $list[$i][wr_link1];
echo "<option value='{$g4_link}'>{$list[$i][subject]}</option>";
}
?>
</select>
</td></tr></table>
<script>
function gofamily(value)
{
if( value == '' ) {
return false;
} else {
name = value;
window.open ('' + name);
}
}
</script>
 
--------------------------------------------------------------------
 
 
 
 
 
도움을 구하고자 하는 글은 이렇습니다.
위 한개의 게시판을 불러오는 '셀렉트문'을 한개가 아닌
 
'분류'별로 각각의 셀렉트문형식으로 '분류갯수'만큼 보여주고자 합니다. [그림 참고]
 
 
이것저것 있는가지고 응용을 해보려 했으나, 원체 스크립터관련해서는 실력이 안되서
구현해 내지를 못하겠군요.
 
 
조금 어려울수도 있을거 같은데...고수분의 도움글을 좀 부탁드리겠습니다. 꾸벅~
 
  • 복사

댓글 전체

아래 코드는

<?
for ($i=0; $i<count($list); $i++){
$g4_link    = $list[$i][wr_link1];
echo "<option value='{$g4_link}'>{$list[$i][subject]}</option>";
}
?>

전에  "select * form BBS_TABLE ..."
가 있었을 것입니다.


카테고리가 ca_name에 있고 인덱스가 되어 있을 때
select * form BBS_TABLE ...order by ca_name and 기타 정렬 기준"

으로 하고

for( mysql_fetch() {

list[ $row['ca_name']]= $row;

}
다음을 ca_name 가짓 수만큼 반복
<?
for ($i=0; $i<count($list[ca_name1]); $i++){
$g4_link    = $list[ca_name1][$i][wr_link1];
echo "<option value='{$g4_link}'>{$list[ca_name1][$i][subject]}</option>";
}
?>
리플 감사합니다..말씀하신 부분을 바탕으로 해보면..(위 질문드린 내용은 먼저 최신글에 해당되므로....)

언급하신 부분에서...

전에  "select * form BBS_TABLE ..."
가 있었을 것입니다. ......................................라고 되어있는것은 
/lib/latest.lib.php 부분을 뜻합니다. 그래서 아래처럼 임시(?)로 수정을 해서 고쳤습니다.

-----------------------------
/lib/latest.lib.php
-----------------------------

<?
// 최신글 추출
function latest($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="")
{
    global $g4;

    if ($skin_dir)
        $latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
    else
        $latest_skin_path = "$g4[path]/skin/latest/basic";

    $list = array();

    $sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
    $board = sql_fetch($sql);

    $tmp_write_table = g4_write_BBS01 ; // 게시판 테이블 전체이름
    $sql = " select * from $tmp_write_table  where wr_is_comment = 0 order by ca_name and wr_id desc limit 0, $rows ";
    //explain($sql);
    $result = sql_query($sql);
    for ($i=0; $row = sql_fetch_array($result); $i++)
        list[ $row['ca_name']]= $row;
   
    ob_start();
    include "$latest_skin_path/latest.skin.php";
    $content = ob_get_contents();
    ob_end_clean();

    return $content;
}
?>


그런다음, 아래 최신글 스킨에서 .. 위 언급하신 코드로 바꿨습니다.


----------------------------------------------------------
lastest.skin_select  (최신글스킨)
---------------------------------------------------------

<table width='100%' align='center'>
<tr align='center'><td>
<select class='category' name='<?=$list[$i][subject]?>' style='width:130' onchange='gofamily(this.value);'>
<option value=''>== <?=$board[bo_subject]?> ==</option>
<?
for ($i=0; $i<count($list[ca_name1]); $i++){
$g4_link    = $list[ca_name1][$i][wr_link1];
echo "<option value='{$g4_link}'>{$list[ca_name1][$i][subject]}</option>";
}
?>
</select>
</td></tr></table>
<script>
function gofamily(value)
{
if( value == '' ) {
return false;
} else {
name = value;
window.open ('' + name);
}
}
</script>






그런다음, 메인에 불러왔으나 안되는군요.....

언급하신, 이코드... list[ $row['ca_name']]= $row;          <------ 맞나요???
for ($i=0; $row = sql_fetch_array($result); $i++)
        $ list[ $row['ca_name']]= $row;
   
    ob_start();

=== 요기를 =========
for ($i=0; $row = sql_fetch_array($result); $i++)
      $ list[ $row['ca_name']]= $row;

foreach( $list as $list_ca){

  echo '<select>';

  for ($i=0; $i<count($list[ca_name1]); $i++){

    $g4_link    = $list_ca[$i][wr_link1];
    echo "<option value='{$g4_link}'>{$list_ca[$i][subject]}</option>";
  }
  echo '</select>';

}


ob_start();
$list 가 바뀌었기 때문에

이 코드 밑에서
include "$latest_skin_path/latest.skin.php";
동작을 안 합니다.
대신
include "$latest_skin_path/latest.skin.php";
바로 위에
$list= $list['카테고리 이름'];
include "$latest_skin_path/latest.skin.php";
로 하세요.
© SIRSOFT
현재 페이지 제일 처음으로