이 코드를 좀 줄일수 없을까요? > 그누4 질문답변

그누4 질문답변

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

이 코드를 좀 줄일수 없을까요? 정보

이 코드를 좀 줄일수 없을까요?

본문

그룹별 폴더를 따로 만들고, 그안에 group_head.php 를 만들어서 파일 상단에다가,
해당 게시판별로 이동시 각각의 '타이틀롤'이 뜨도록 아래와 같이 코드를 만들었습니다.
 
- 해당게시판 링크를 클릭하면 이동후,
if문에서 지정한 테이블명이면 ... $board[bo_subject] 값을 불러오도록 되어있습니다.
 
- 그리고 그옆에는 '현재위치'를 표시해주는 파일을 인클루드 시켰고요.
  ($DOCUMENT_ROOT."/_common/page_location2.php)
 
 
 
원하는대로 작동은 잘됩니다. 그러나 아래 코드를 쭈욱 보시면 아시겠지만...
 
if문에 의한 '테이블명'만 다를뿐, 똑같은 코드가 반복됩니다.
 
이 코드를 좀더 깔끔하게 줄일수 없을까요?
 
해당그룹의 게시판이 한 60개정도되는건 이런식으로 불러오려니,
상당히 부담스럽게(?) 느껴집니다.
 
배열 or 기타 루프문으로 처리를 하면 어떻게 될거 같은데..실력이 좀 안되는군요.
 
고수분의 도움글을 좀 부탁드립니다.
 
P.S; 아래내용은 실제사용중인 코드이고 아래코드를 적용해서 처리를 해야합니다. ^^;;
 
 
 
---------------------------------------
테이블명에 의한 게시판명 불러오기 코드
---------------------------------------
 
 
 
 
<!--  게시판 타이틀및 현재위치 테이블 시작 -->
<? if($bo_table == 'tmy_01b00') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_01b01') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_01b02') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_01b03') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_01b04') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_01b05') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_01b06') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_01b07') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_01b08') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_01b09') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_01b10') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_01b11') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_01b12') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_01b13') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_02b01') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_02b02') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_02b03') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_02b04') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_02b05') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_02b06') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_02bw1') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_02bw2') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_09b01') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_09b02') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_09b03') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_09b04') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? }else if($bo_table == 'tmy_09b05') { // 게시판명 ?>
 <table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>
 
<? } else { // 메인화면 타이틀 ?>
<? } ?>
<!--  게시판 타이틀및 현재위치 테이블 끝 -->

댓글 전체

제가 대충 코드 개념만 올려드리니 php 문법은 정리하세요.

<?
switch ($bo_table) {
case 'tmp_09b01':
case 'tmp_09b02':
case 'tmp_09b03':
case 'tmp_09b04':
case 'tmp_09b05':
?>

<table width=100% cellpadding=0 cellspacing=0 border=0 style='border-bottom:1px solid #DEDEDE'>
 <tr height=26>
 <td width='180' style='padding:0 0 0 0'><img src='/_common/imgs/icon_direct.gif' width='20' height='14' align='absmiddle'><?=$board[bo_subject]?></span></td>
 <td width='' align='right'><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></td>
 </tr></table>

<?
break;
default:
// 메인타이틀...
}
?>
제가보기엔 테이블 html테그를 div로 바꾸고 그각각의 div에 id를 지정한다음
css에 해당 속성을 추가하시면 될듯하네요.

예]
<div id='m'>
<ul  style="left:10px;top:7px;color:#0780B2;"><?=$board[bo_subject]?></ul>
<ul  style="left:100px;top:7px;color:#0780B2;"><? include $DOCUMENT_ROOT."/_common/page_location2.php"; ?></ul>
</div>

이런형태..
오호~~ 불당님... ^^ ;;

감사합니다. 정말 아주 간단해졌군요.
case문 마다 바로 실행문을 넣어야만 하는걸로 생각해서 별반 if문처리와 다를바 없다고
생각했었는데 그게 아니였군요. ^^ ;;

덕분에 한수 배운거 같습니다. 감사~~

모두들 구정 잘 보내시길 바랍니다.
근데 ... 흠..채택된 답변외에 별도의 문제가 하나 생겨버렸군요.

일반 tml 페이지가 있는경우는 제목을 뿌려주기가 난감스러운 부분이 있군요.

게시판은 위처럼 적용하면 되는데
a.html  / b.php 등과 같은 임의의 html or php 파일을 만들었을때
head.php 부분에서 게시판처럼 타이틀을 뿌려주는게 ~~ 쉽지않군요. ^^ ;;


기존에는 ... 위 질문에서 처럼 if문으로 '해당경로내'에
임의의 php or html 파일이 있는 경우 해당 타이틀부분을 아래처럼...실행했었는데...


<? } if(preg_match("/임의의생성파일.html/", $_SERVER[REQUEST_URI])){ ?>
<img src='/tmz/imgs/mu_tit_d006.gif' height='40' width='350'>
</td><td width='' height='40' background='/tmz/imgs/mu_tit_bg.gif'>&nbsp;</td>
<tr><td colspan=2 height=4 bgcolor=F7F7F7></td></tr>
<tr><td colspan=2 height=1 bgcolor=E4E4E4></td></tr>


case문으로 위부분을 실행하기에는 약간의 문제가 있군요...
고민해야 할 부분...
전체 66,554 |RSS
그누4 질문답변 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT