트리플님 전체 게시판관리 에서 아이디검색을 제목검색으로 할려고합니다.

트리플님 전체 게시판관리 에서 아이디검색을 제목검색으로 할려고합니다.

QA

트리플님 전체 게시판관리 에서 아이디검색을 제목검색으로 할려고합니다.

본문

트리플님 전체 게시판관리 에서 아이디검색을 제목검색으로 할려고합니다.

 

<label for="stx" class="sound_only">검색어</label>
<input type="text" name="stx" value="<?php echo $stx ?>" id="stx" class="frm_input">
<input type="submit" value="검색" class="btn_submit">

 

이거를 아래처럼 변경햇는데 검색이 않됩니다.

 

<select name="sfl" id="sfl">
    <option value="wr_subject"<?php echo get_selected($_GET['sfl'], "wr_subject"); ?>>제목</option>
</select>
<label for="stx" class="sound_only">검색어<strong class="sound_only"> 필수</strong></label>
<input type="text" name="stx" value="<?php echo $stx ?>" id="stx" class="frm_input">
<input type="submit" class="btn_submit" value="검색">

 


이거를 어떻게 수정 하면은 제목 검색으로 됩니까?

 

고수님 도와주세요 

감사 합니다

 

 

 

 

<?php
$sub_menu = "300900";
include_once('./_common.php');

auth_check($auth[$sub_menu], 'r');

$sql_common = " from {$g5['board_new_table']} a, {$g5['board_table']} b, {$g5['group_table']} c 
               where a.bo_table = b.bo_table and b.gr_id = c.gr_id and b.bo_use_search = '1' ";

if ($gr_id){
    $sql_common .= " and b.gr_id = '$gr_id' ";
    $qstr .= "&gr_id=$gr_id";
}

if ($bo_table){
    $sql_common .= " and a.bo_table = '$bo_table' "; //여기가 추가된 부분 
    $qstr .= "&bo_table=$bo_table";
}

if ($view == "w"){
    $sql_common .= " and a.wr_id = a.wr_parent ";
    $qstr .= "&view=$view";
}

else if ($view == "c") {
     $sql_common .= " and a.wr_id <> a.wr_parent ";
     $qstr .= "&view=$view";
}

if ($mb_id) {
     $sql_common .= " and a.mb_id = '$mb_id' ";
     $qstr .= "&mb_id=$mb_id";
     //출석 체크
    if($member['mb_id']) chulcheck($member[mb_id]);
}
   
if (!$sst) {
$sst  = "a.bn_id";
$sod = "desc";
}

if($sst) {
     $qstr .= "&sst=$sst";
     $qstr .= "&sod=$sod";
}

$sql_order = " order by $sst $sod";
$sql = " select count(*) as cnt $sql_common ";
$row = sql_fetch($sql);

$total_count = $row[cnt];
if ($pgview) {
    $rows = $pgview;
    $qstr .= "&pgview=$pgview";
} else {
    $rows = $config[cf_new_rows];
}

$total_page  = ceil($total_count / $rows);  // 전체 페이지 계산
if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함

$group_select = "<select name=gr_id id=gr_id onchange='select_change();'><option value=''>전체그룹";
$sql = " select gr_id, gr_subject from {$g5['group_table']} order by gr_id ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) 
{
    $selected = ($gr_id == $row['gr_id']) ? "selected=selected" : "";
    $group_select .= "<option $selected value='$row[gr_id]'>$row[gr_subject]";
}
$group_select .= "</select>";
$board_select = "<select name=bo_table id=bo_table onchange='select_change();'><option value=''>전체게시판";

if($gr_id)
    $sql_extra  = "where gr_id = '$gr_id'";
$sql = " select bo_table, bo_subject from {$g5['board_table']} $sql_extra order by bo_table";

$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) 
{
    $selected = ($bo_table == $row['bo_table']) ? "selected=selected" : "";
    $board_select .= "<option $selected  value='$row[bo_table]'>$row[bo_subject]";
}
$board_select .= "</select>";

$list = array();
$sql = " select a.*, b.bo_subject, c.gr_subject, c.gr_id
          $sql_common
          $sql_order
          limit $from_record, $rows ";

$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) 
{
    $tmp_write_table = $g5['write_prefix'] . $row[bo_table];

    if ($row[wr_id] == $row[wr_parent]) // 원글
    {
        $comment = "";
        $comment_link = "";
        $row2 = sql_fetch(" select * from $tmp_write_table where wr_id = '$row[wr_id]' ");
        $list[$i] = $row2;
        $name = get_sideview($row2[mb_id], cut_str($row2[wr_name], $config[cf_cut_name]), $row2[wr_email], $row2[wr_homepage]);
        // 당일인 경우 시간으로 표시함
        $datetime = $row2[wr_datetime];
    }
    else // 코멘트
    {
        $comment = "<font color='#FF0000'>[코]</font> ";
        $comment_link = "#c_{$row[wr_id]}";
        //$row2 = sql_fetch(" select * from $tmp_write_table where wr_id = '$row[wr_parent]' ");
        $row2 = sql_fetch(" select * from $tmp_write_table where wr_id = '$row[wr_id]' ");
        $row3 = sql_fetch(" select mb_id, wr_name, wr_email, wr_homepage, wr_datetime from $tmp_write_table where wr_id = '$row[wr_id]' ");
        $list[$i] = $row2;
        $list[$i][mb_id] = $row3[mb_id];
        $list[$i][wr_name] = $row3[wr_name];
        $list[$i][wr_email] = $row3[wr_email];
        $list[$i][wr_homepage] = $row3[wr_homepage];
        $name = get_sideview($row3[mb_id], cut_str($row3[wr_name], $config[cf_cut_name]), $row3[wr_email], $row3[wr_homepage]);
        $datetime = $row3[wr_datetime];
        $row2[wr_subject] = $row2[wr_content];
    }
    $list[$i][gr_id] = $row[gr_id];
    $list[$i][bo_table] = $row[bo_table];
    $list[$i][name] = $name;
    $list[$i][comment] = $comment;
    $list[$i][href] = "../bbs/board.php?bo_table=$row[bo_table]&wr_id=$row2[wr_id]{$comment_link}";
    $list[$i][datetime] = $datetime;
    $list[$i][gr_subject] = $row[gr_subject];
    $list[$i][bo_subject] = $row[bo_subject];
    $list[$i][wr_subject] = $row2[wr_subject];
}
$html_title = '전체 게시판 HIT 관리';
$g5['title'] = $html_title;
include_once('./admin.head.php');
?>
<style>
.frm_input {
    height: 22px;
    line-height: 22px;
    border: 1px solid #d5d5d5;
}
</style>
<!-- 분류 시작 -->
<form name="fnew" id="fnew" class="local_sch01 local_sch" method="get">
    <?=$group_select?>
    <?=$board_select?>
<label for="view" class="sound_only">전체게시물,원글,코멘트중에 선택하세요</label>
<select name='view' id='view' onchange="select_change()">
    <option value=''>전체게시물
    <option value='w'>원글만
    <option value='c'>코멘트만
</select>
<label for="pgview" class="sound_only">출력개수를 선택하세요</label>
<select name='pgview' id='pgview' onchange="select_change()">
    <option value=''>출력개수
    <option value='1'>1개
    <option value='15'>15개
    <option value='30'>30개
    <option value='50'>50개
    <option value='100'>100개
    <option value='150'>150개
    <option value='200'>200개
    <option value='300'>300개
    <option value='500'>500개
</select>

<select name="sfl" id="sfl">
    <option value="wr_subject"<?php echo get_selected($_GET['sfl'], "wr_subject"); ?>>제목</option>
</select>
<label for="stx" class="sound_only">검색어<strong class="sound_only"> 필수</strong></label>
<input type="text" name="stx" value="<?php echo $stx ?>" id="stx" class="frm_input">
<input type="submit" class="btn_submit" value="검색">
</form>
<!-- 분류 끝 -->

<form name="fboardlist" id="fboardlist" action="./new_hit_list_update.php" onsubmit="return fboardlist_submit(this);" method="post">
<input type=hidden name='gr_id' value='<?php echo $gr_id; ?>' />
<input type=hidden name='bo_table' value='<?php echo $bo_table; ?>' />
<input type=hidden name='view' value='<?php echo $view; ?>' />
<input type=hidden name='mb_id' value='<?php echo $mb_id; ?>' />
<input type=hidden name='pgview' value='<?php echo $pgview; ?>' />
<input type=hidden name='page' value='<?php echo $page; ?>' />
<input type=hidden name='sst' value='<?php echo $sst; ?>' />
<input type=hidden name='sod' value='<?php echo $sod; ?>' />

<div class="tbl_head01 tbl_wrap">
<table>
    <caption><?php echo $g5['title']; ?> 목록</caption>
    <colgroup>
        <col width="30px" />
        <col width="120px" />
        <col width="120px" />
        <col width="" />
        <col width="120px" />
        <col width="120px" />
        <col width="300px" />
        <col width="120px" />
        <col width="120px" />
    </colgroup>
    <thead>
    <tr>
        <th scope="col">
            <label for="chkall" class="sound_only">전체선택</label>
            <input type="checkbox" name="chkall" value="1" id="chkall" onclick="check_all(this.form)">
        </th>
        <th scope="col"><?=subject_sort_link("gr_id",$qstr)?>그룹</a></th>
        <th scope="col"><?=subject_sort_link("bo_table",$qstr)?>게시판</a></th>
        <th scope="col"><?=subject_sort_link("bo_subject",$qstr)?>제목</a></th>
        <th scope="col"><?=subject_sort_link("mb_id",$qstr)?>이름</a></th>
        <th scope="col"><?=subject_sort_link("mb_id",$qstr)?>작성자</a></th>
        <th scope="col"><?=subject_sort_link("bn_datetime",$qstr)?>일시</a></th>
        <th scope="col">추천</th>
        <th scope="col">조회</th>
    </tr>
    </thead>
    <tbody>
<?php
for ($i=0; $i<count($list); $i++)
{
    $gr_subject = cut_str($list[$i][gr_subject], 20);
    $bo_subject = cut_str($list[$i][bo_subject], 20);
    $wr_subject = get_text(cut_str($list[$i][wr_subject], 80));
    $datetime3 = substr($list[$i][wr_datetime],0,19);

    $bg = 'bg'.($i%2);

    if($list[$i][wr_hit] >= 500){
        $random=rand(1,2);
    } else if($list[$i][wr_hit] >= 300){
        $random=rand(1,3);
    } else {
        $random=rand(2,7);
    }
    
////////////////// 추천 랜덤조작 시작 //////////////////
    $random_good=rand(0,2);
////////////////// 추천 랜덤조작 시작 //////////////////

/*
////////////////// 작성일 랜덤조작 시작 //////////////////
    $random_D=rand(14,14);//일
    $random_H=rand(8,15);//시
    $random_I=rand(1,59);//분

    $timestamp = strtotime(date("2020-05-".$random_D." ".$random_H.":".$random_I.":s")."");
    $time = date("Y-m-d H:i:s", $timestamp);
////////////////// 작성일 랜덤조작 끝 //////////////////
*/
?>
    <tr class="<?php echo $bg; ?>">
        <td class="td_chk">
            <label for="chk_<?php echo $i; ?>" class="sound_only"><?php echo $list[$i][wr_id] ?>번글 선택</label>
            <input class='chk' type="checkbox" name="chk[]" value="<?php echo $i; ?>">
            <input type=hidden name=set_table[<?=$i?>]  value='<?=$list[$i]['bo_table']?>'>
            <input type=hidden name=set_id[<?=$i?>]  value='<?=$list[$i]['wr_id']?>'>
        </td>
        <td><a href='./new_hit_list.php?gr_id=<?=$list[$i][gr_id]?>'><?=$gr_subject?></a></td>
        <td><a href='<?=G5_BBS_URL ?>/board.php?bo_table=<?=$list[$i][bo_table]?>'><?=$bo_subject?></a></td>
        <td><a href='<?=$list[$i][href]?>'><div style="width:100%; text-align:left;"><?=$list[$i][comment]?><?=$wr_subject?></div></a></td>
        <td style="text-align:left;"><?=$list[$i][name]?></td>
        
        <td><input type=text size=12 name=set_cb_mb_id[<?=$i?>] value="<?=$list[$i][mb_id]; ?>" class="frm_input"></td>
        
        <td align='center'>
            <label for="chk_date<?php echo $i; ?>" class="sound_only"><?php echo $list[$i][wr_id] ?>번글 날짜변경 사용</label>
            
            <!-----
            <input type=text size=16 name=set_date[<?=$i?>]  value='<?php echo $time; ?>' class="frm_input set_date" style="width:120px;">
            ------->
            
            <input type=text size=16 name=set_date[<?=$i?>]  value='<?php echo $list[$i][datetime]; ?>' class="frm_input set_date" style="width:125px;">
            
            <span><?=$list[$i][datetime]?></span>
        </td>

        <td align='center'>
        <input type=text size=3 name=set_good[<?=$i?>]  value='<?php echo ((int)$list[$i][wr_good]+$random_good) ?>' class="frm_input" style="width:50px;">
        <span title='현제 hit' > / <?=$list[$i][wr_good]?></span>
        </td>
        <td style="text-align:left;">
        <input type=text size=3 name=set_hit[<?=$i?>] value='<?php echo ((int)$list[$i][wr_hit]+$random) ?>' class="frm_input" maxlength="5" style="width:50px;">
        <span title='현제 hit' > / <?=$list[$i][wr_hit]?></span>
        </td>
    </tr>
    <?php } 
    if ($i == 0)
        echo '<tr><td colspan="8" class="empty_table">자료가 없습니다.</td></tr>';
    ?>
    </tbody>
</table>
</div>
<div class="btn_list01 btn_list"><input type="submit" name="act_button" value="선택수정" onclick="document.pressed=this.value" class="btn_01 btn"></div>
</form>
<?php echo get_paging(G5_IS_MOBILE ? $config['cf_mobile_pages'] : $config['cf_write_pages'], $page, $total_page, $_SERVER['PHP_SELF'].'?'.$qstr.'&page='); ?>
<script language="JavaScript">
function fboardlist_submit(f)
{
    if (!is_checked("chk[]")) {
        alert(document.pressed+" 하실 항목을 하나 이상 선택하세요.");
        return false;
    }
    return true;
}
function select_change()
{
    var f = document.fnew;
    document.fnew.submit();
}
//    document.getElementById("gr_id").value = "<?=$gr_id?>";
//    document.getElementById("bo_table").value = "<?=$bo_table?>";
document.getElementById("pgview").value = "<?=$pgview?>";
document.getElementById("view").value = "<?=$view?>";
</script> 

<script type="text/javascript">
/* Korean initialisation for the jQuery calendar extension. */
/* Written by DaeKwon Kang (*** 개인정보보호를 위한 이메일주소 노출방지 ***). */
jQuery(function($){
    $.datepicker.regional['ko'] = {
        closeText: '닫기',
        prevText: '이전달',
        nextText: '다음달',
        currentText: '오늘',
        monthNames: ['1월(JAN)','2월(FEB)','3월(MAR)','4월(APR)','5월(MAY)','6월(JUN)',
        '7월(JUL)','8월(AUG)','9월(SEP)','10월(OCT)','11월(NOV)','12월(DEC)'],
        monthNamesShort: ['1월','2월','3월','4월','5월','6월',
        '7월','8월','9월','10월','11월','12월'],
        dayNames: ['일','월','화','수','목','금','토'],
        dayNamesShort: ['일','월','화','수','목','금','토'],
        dayNamesMin: ['일','월','화','수','목','금','토'],
        weekHeader: 'Wk',
        dateFormat: 'yymmdd',
        firstDay: 0,
        isRTL: false,
        showMonthAfterYear: true,
        yearSuffix: ''};
    $.datepicker.setDefaults($.datepicker.regional['ko']);

    $('.set_date').datetimepicker({
        
        showOn: 'none',
        // buttonImage: '/img/calendar.gif',
        buttonImageOnly: true,
        buttonText: "달력",
        changeMonth: true,
        changeYear: true,
        showButtonPanel: true,
        dateFormat: 'yy-mm-dd',
        timeFormat:  'HH:mm:ss',
        
        controlType: 'select',
        oneLine: true,
        yearRange: 'c-99:c+99'
    }); 
$('.set_date').on('click focus',function(){
    $(this).datetimepicker('show');
    
});    
});
</script>
<?php
include_once ('./admin.tail.php');
?>

이 질문에 댓글 쓰기 :

답변 2

개인적인 생각으로는 조건문을 추가하면 되지 않을까 생각합니다.


// 검색 조건에 따라 SQL 쿼리 수정
if ($_GET['sfl'] == "wr_subject") {
    $sql_common .= " and (a.wr_subject like '%$stx%' or a.wr_content like '%$stx%') ";
} else {
    // 다른 검색 조건이 추가되었을 경우 여기에 추가
}

다음 코드를 넣으면 검색은 되지만 하단 페이징이 맞지않게 됩니다 

제목을 검색하여 내용이 없는데 페이지 갯수는 2개 나온다든지, 검색 내용은 1개 뿐인데 

페이지는 2페이지가 된다든지....

억지 춘향식으로 만들면 되기야 하겠지만 total페이지 계산 부분은

제목 검색을 넣어서 어떻게 해볼 수 있는 것이 아닙니다

 

어쨌든 검색 하기

$list = array(); 다음행에 추가

if(isset($sfl) && isset($stx) && $stx){

  $sql_common .= " and INSTR(a.wr_subject, '$stx') "; 
    $qstr .= "&sfl=$sfl&stx=$stx";

}

 

제목을 검색에 사용하려면 g5_board_new 테이블에 제목을 기록하도록

필드를 추가하는 것이 좋을 것입니다

 

 

답변을 작성하시기 전에 로그인 해주세요.
전체 14,981
QA 내용 검색
filter #php ×

회원로그인

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