정렬이 되지않습니다 질문드립니다.

정렬이 되지않습니다 질문드립니다.

QA

정렬이 되지않습니다 질문드립니다.

본문

사이트주소는 여기입니다.

 

http://iconoptics.edenstore.co.kr/bbs/board.php?bo_table=board_gallery&sop=and&sst=wr_3&sod=asc&sfl=wr_subject||wr_1||wr_2||wr_3||wr_4||wr_5||wr_6||wr_7||wr_8||wr_9||wr_10||wr_11||wr_12||wr_13||wr_14||wr_15||wr_16&stx=&page=1

 

 

 

 

1순위 정렬 하고 그 순위가 같으면 2순위 정렬을 하려고합니다.

 

 


if(!$sst)
    $sst  = "wr_num, wr_reply";

if ($sst) {
//    $sql_order = " order by {$sst} {$sod}, wr_4 asc, wr_2 ASC ";
    if($bo_table=="board_gallery"){
        $sql_order = " order by {$sst} {$sod}, wr_4 {$sod}";
    }else{
        $sql_order = " order by {$sst} {$sod}";
    }
}

 

 

정렬부분 소스입니다. 처음정렬하고 같으면 wr_4 가 정렬 되게해두었습니다.

 

wr_4는 WD입니다.

 

3731834642_1602483356.6882.png

 

이상태에서 아래 fov 정렬 두개는 잘되는데

 

나머지 mag와 wd , image 정렬 3개는 2순위 정렬이되지않고 있습니다.

 

2순위는 WD정렬입니다.

 

3731834642_1602483691.6515.png

 

보시다시피 MAG 정렬 오름차순으로 했을때 2순위 정렬 WD 가 정렬이 제대로 이루어지지않은것을 확인할수잇습니다 

 

마지막으로 등록된 FOV는 정렬이 오름차순, 내림차순으로 했을때 2순위 정렬까지 다 잘되는데 나머지는 정렬이 잘 안되는이유를 모르겠습니다 .

 

어디부분을 좀더 손봐야할까요 ?

 

 

 

 

 

 

echo로 sql 찍어보았습니다.

 

select * from g5_write_board_gallery where wr_is_comment = 0 order by wr_1 asc, wr_4 asc limit 0, 30

 

라고나옵니다.

 

이부분을 sql에다가 출력하니까

 

 

3731834642_1602572813.8986.png

???

 

wr_1에관해서 wr_4가 제대로 정렬이 오름차순으로 진행되는것을확인할수가 있습니다.

 

그런데 홈페이지에서는 이것이 제대로 이루어지지않습니다

 

왜 이런현상이 일어나는걸까요 ?

이 질문에 댓글 쓰기 :

답변 2

sql_fetch해서 나온 result를

var_dump로 찍어보세요

가져온 순서도 정렬이 되서 가져와지는지

// 페이지의 공지개수가 목록수 보다 작을 때만 실행
if($page_rows > 0) {
    $result = sql_query($sql);

    $k = 0;

    while ($row = sql_fetch_array($result))
    {
        // 검색일 경우 wr_id만 얻었으므로 다시 한행을 얻는다
        if ($sca || $stx)
            $row = sql_fetch(" select * from {$write_table} where wr_id = '{$row['wr_parent']}' ");

        $list[$i] = get_list($row, $board, $board_skin_url, G5_IS_MOBILE ? $board['bo_mobile_subject_len'] : $board['bo_subject_len']);
        if (strstr($sfl, 'subject')) {
            $list[$i]['subject'] = search_font($stx, $list[$i]['subject']);
        }
        $list[$i]['is_notice'] = false;
        $list_num = $total_count - ($page - 1) * $list_page_rows - $notice_count;
        $list[$i]['num'] = $list_num - $k;

        $i++;
        $k++;
    }
}
var_dump($row);


이부분맞나요 ?

bool(false)

라고나옵니다

var_dump($list[1]);

이런식으로해서 출력된값을 보니 wr_4의 값이 280.2였습니다.
즉 마지막 사진 같이 DB값을 가져온것이 아닌 정렬 이상 있는 상태로 가져왓습니다.
sql를 출력했을때 명령문에는 문제가없는데 왜그런건가요 ?

그럼 실제 실행되는 sql을 잘못 넣었거나
php 자체가 다중 정렬을 인식못한다거나,, 이경우는 아마 아닐거같고
쿼리문이 완성되고 쿼리를 찍는부분도 봐야될거같네요

var_dump(sql_fetch($result)); 라고 적으면에러나서

var_dump(sql_fetch_array($result)); 로해서 출력해보았습니다.


array(49) { ["wr_id"]=> string(3) "131" ["wr_num"]=> string(4) "-113" ["wr_reply"]=> string(0) "" ["wr_parent"]=> string(3) "131" ["wr_is_comment"]=> string(1) "0" ["wr_comment"]=> string(1) "0" ["wr_comment_reply"]=> string(0) "" ["ca_name"]=> string(0) "" ["wr_option"]=> string(0) "" ["wr_subject"]=> string(13) "0.12x-280d-11" ["wr_content"]=> string(1) "." ["wr_link1"]=> string(0) "" ["wr_link2"]=> string(0) "" ["wr_link1_hit"]=> string(1) "0" ["wr_link2_hit"]=> string(1) "0" ["wr_hit"]=> string(3) "551" ["wr_good"]=> string(1) "0" ["wr_nogood"]=> string(1) "0" ["mb_id"]=> string(10) "iconoptics" ["wr_password"]=> string(41) "*" ["wr_name"]=> string(9) "" ["wr_email"]=> string(14) "" ["wr_homepage"]=> string(0) "" ["wr_datetime"]=> string(19) "2018-09-13 16:53:53" ["wr_file"]=> string(1) "3" ["wr_last"]=> string(19) "2018-09-13 16:53:53" ["wr_ip"]=> string(12) "" ["wr_facebook_user"]=> string(0) "" ["wr_twitter_user"]=> string(0) "" ["wr_1"]=> string(4) "0.12" ["wr_2"]=> string(2) "11" ["wr_3"]=> string(5) "91.76" ["wr_4"]=> string(3) "280" ["wr_5"]=> string(2) "33" ["wr_6"]=> string(1) "6" ["wr_7"]=> string(4) "0.01" ["wr_8"]=> string(3) "7.2" ["wr_9"]=> string(4) "0.07" ["wr_10"]=> string(4) "0.09" ["wr_11"]=> string(1) "x" ["wr_12"]=> string(1) "o" ["wr_13"]=> string(1) "c" ["wr_14"]=> string(3) "2/3" ["wr_15"]=> string(5) "585.5" ["wr_16"]=> string(0) "" ["wr_17"]=> string(0) "" ["wr_18"]=> string(0) "" ["wr_19"]=> string(0) "" ["wr_20"]=> string(0) "" }

$row = sql_fetch(" select * from {$write_table} where wr_id = '{$row['wr_parent']}' ");

$list[$i] = get_list($row, $board, $board_skin_url, G5_IS_MOBILE ? $board['bo_mobile_subject_len'] : $board['bo_subject_len']);

여기가 실행되면서 꼬이는게 아닐까 싶네요

이부분도 하나씩 까보면서 해결해보셔야될거같아요

$row = sql_fetch(" select * from {$write_table} where wr_id = '{$row['wr_parent']}' ");

이부분은 삭제해도 변동사항이 없었습니다. 아마 검색이아니라서 이부분은 진행이안되는거같습니다.

그래서

$list[$i] = get_list($row, $board, $board_skin_url, G5_IS_MOBILE ? $board['bo_mobile_subject_len'] : $board['bo_subject_len']);

이부분에서 var_dump($list[0])을 진행해보았더니

 ["wr_1"]=> string(4) "0.12" ["wr_2"]=> string(2) "11" ["wr_3"]=> string(5) "91.76" ["wr_4"]=> string(3) "280"



["wr_4"]=> string(3) "280"

그대로 나왔습니다

get_list에 검색조건을 어떻게 넣는건가요 ?

$list[$i] = get_list($row, $board, $board_skin_url, G5_IS_MOBILE ? $board['bo_mobile_subject_len'] : $board['bo_subject_len']);

이부분에

if ($sca || $stx)
            $row = sql_fetch(" select * from {$write_table} where wr_id = '{$row['wr_parent']}' ");

이부분을 추가를 어떻게 해야하는건가요 ?

get_list 자체는 그누에 포함된 함수라서 이걸 수정을해야하는데
get_list를 찾아서 복붙한후
get_list2로 변경 검색조건받는 변수 추가,
검색변수를 포함해서 리스트 검색 후 리턴
이렇게 수정해야하는데
가장중요한건 이게 맞냐 틀리냐를 아직 모르고있다는거죠,,
의심만될뿐

lib > common.lib.php에서 찾았습니다.







// 게시물 정보($write_row)를 출력하기 위하여 $list로 가공된 정보를 복사 및 가공
function get_list($write_row, $board, $skin_url, $subject_len=40)
{
    global $g5, $config;
    global $qstr, $page;

    //$t = get_microtime();

    // 배열전체를 복사
    $list = $write_row;
    unset($write_row);

    $board_notice = array_map('trim', explode(',', $board['bo_notice']));
    $list['is_notice'] = in_array($list['wr_id'], $board_notice);

    if ($subject_len)
        $list['subject'] = conv_subject($list['wr_subject'], $subject_len, '…');
    else
        $list['subject'] = conv_subject($list['wr_subject'], $board['bo_subject_len'], '…');

    // 목록에서 내용 미리보기 사용한 게시판만 내용을 변환함 (속도 향상) : kkal3(커피)님께서 알려주셨습니다.
    if ($board['bo_use_list_content'])
{
$html = 0;
if (strstr($list['wr_option'], 'html1'))
$html = 1;
else if (strstr($list['wr_option'], 'html2'))
$html = 2;

        $list['content'] = conv_content($list['wr_content'], $html);
}

    $list['comment_cnt'] = '';
    if ($list['wr_comment'])
        $list['comment_cnt'] = "<span class=\"cnt_cmt\">".$list['wr_comment']."</span>";

    // 당일인 경우 시간으로 표시함
    $list['datetime'] = substr($list['wr_datetime'],0,10);
    $list['datetime2'] = $list['wr_datetime'];
    if ($list['datetime'] == G5_TIME_YMD)
        $list['datetime2'] = substr($list['datetime2'],11,5);
    else
        $list['datetime2'] = substr($list['datetime2'],5,5);
    // 4.1
    $list['last'] = substr($list['wr_last'],0,10);
    $list['last2'] = $list['wr_last'];
    if ($list['last'] == G5_TIME_YMD)
        $list['last2'] = substr($list['last2'],11,5);
    else
        $list['last2'] = substr($list['last2'],5,5);

    $list['wr_homepage'] = get_text(addslashes($list['wr_homepage']));

    $tmp_name = get_text(cut_str($list['wr_name'], $config['cf_cut_name'])); // 설정된 자리수 만큼만 이름 출력
    if ($board['bo_use_sideview'])
        $list['name'] = get_sideview($list['mb_id'], $tmp_name, $list['wr_email'], $list['wr_homepage']);
    else
        $list['name'] = '<span class="'.($list['mb_id']?'sv_member':'sv_guest').'">'.$tmp_name.'</span>';

    $reply = $list['wr_reply'];

    $list['reply'] = strlen($reply)*10;

    $list['icon_reply'] = '';
    if ($list['reply'])
        $list['icon_reply'] = '<img src="'.$skin_url.'/img/icon_reply.gif" style="margin-left:'.$list['reply'].'px;" alt="답변글">';

    $list['icon_link'] = '';
    if ($list['wr_link1'] || $list['wr_link2'])
        $list['icon_link'] = '<img src="'.$skin_url.'/img/icon_link.gif" alt="관련링크">';

    // 분류명 링크
    $list['ca_name_href'] = G5_BBS_URL.'/board.php?bo_table='.$board['bo_table'].'&amp;sca='.urlencode($list['ca_name']);

    $list['href'] = G5_BBS_URL.'/board.php?bo_table='.$board['bo_table'].'&amp;wr_id='.$list['wr_id'].$qstr;
    $list['comment_href'] = $list['href'];

    $list['icon_new'] = '';
    if ($board['bo_new'] && $list['wr_datetime'] >= date("Y-m-d H:i:s", G5_SERVER_TIME - ($board['bo_new'] * 3600)))
        $list['icon_new'] = '<img src="'.$skin_url.'/img/icon_new.gif" alt="새글">';

    $list['icon_hot'] = '';
    if ($board['bo_hot'] && $list['wr_hit'] >= $board['bo_hot'])
        $list['icon_hot'] = '<img src="'.$skin_url.'/img/icon_hot.gif" alt="인기글">';

    $list['icon_secret'] = '';
    if (strstr($list['wr_option'], 'secret'))
        $list['icon_secret'] = '<img src="'.$skin_url.'/img/icon_secret.gif" alt="비밀글">';

    // 링크
    for ($i=1; $i<=G5_LINK_COUNT; $i++) {
        $list['link'][$i] = set_http(get_text($list["wr_link{$i}"]));
        $list['link_href'][$i] = G5_BBS_URL.'/link.php?bo_table='.$board['bo_table'].'&amp;wr_id='.$list['wr_id'].'&amp;no='.$i.$qstr;
        $list['link_hit'][$i] = (int)$list["wr_link{$i}_hit"];
    }

    // 가변 파일
    if ($board['bo_use_list_file'] || ($list['wr_file'] && $subject_len == 255) /* view 인 경우 */) {
        $list['file'] = get_file($board['bo_table'], $list['wr_id']);
    } else {
        $list['file']['count'] = $list['wr_file'];
    }

    if ($list['file']['count'])
        $list['icon_file'] = '<img src="'.$skin_url.'/img/icon_file.gif" alt="첨부파일">';

    return $list;
}









의심되더라도 해보고싶습니다. 이걸 2로 바꾼뒤에 소스 어느걸 추가하면될까요 ?

get_list 내부에선 조회하는부분이 없네요 그럼 다시 위로 올라가서
현재까진 1번만 찍어봐서 모든 배열이 정상적으로 호출됐다고 볼수없으니
반복문에서
echo $list[$i]['wr_4]."<br/>";
로 모든 배열을 찍어봐야겠네요

list.skin.php에서

for문있는곳에서

<?php
        for ($i=0; $i<count($list); $i++) {
echo $list[$i]['wr_4']."<br/>";
$thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height']);

if($thumb['src']) {
$img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" width="'.$board['bo_gallery_width'].'" >';
} else {
$img_content = '';
}

$list[$i][file] =get_file($bo_table, $list[$i][wr_id]);
$imagepath = $list[$i][file][0][path]."/".$list[$i][file][0][file];

        ?>




echo $list[$i]['wr_4']."<br/>";

로 찍으니

280.2
280
201.1
111
110
160.5
251.7
280
140
166.5
109.4
132
163
125
197.5
120
98.5
190
340.5
200
200
97
97
217
217
172
172
117
289
289


으로 나왔습니다

즉 DB처럼 안나왔습니다.

if($page_rows > 0) {
    $result = sql_query($sql);

    $k = 0;

    while ($row = sql_fetch_array($result))
    {
        // 검색일 경우 wr_id만 얻었으므로 다시 한행을 얻는다
        if ($sca || $stx)
            $row = sql_fetch(" select * from {$write_table} where wr_id = '{$row['wr_parent']}' ");

        $list[$i] = get_list($row, $board, $board_skin_url, G5_IS_MOBILE ? $board['bo_mobile_subject_len'] : $board['bo_subject_len']);
        if (strstr($sfl, 'subject')) {
            $list[$i]['subject'] = search_font($stx, $list[$i]['subject']);
        }
        $list[$i]['is_notice'] = false;
        $list_num = $total_count - ($page - 1) * $list_page_rows - $notice_count;
        $list[$i]['num'] = $list_num - $k;

        $i++;
        $k++;
    }
}

이부분이 끝나고

$list를 변경시키거나 하는부분이 있는지 찾아보셔야될거같네요

위 소스에선 디비와 같이 나오는데

skin으로 넘어가선 순서가 바뀐다?

말씀하신부분에서


// 페이지의 공지개수가 목록수 보다 작을 때만 실행
if($page_rows > 0) {
    $result = sql_query($sql);

    $k = 0;

    while ($row = sql_fetch_array($result))
    {
        // 검색일 경우 wr_id만 얻었으므로 다시 한행을 얻는다
        if ($sca || $stx)
            $row = sql_fetch(" select * from {$write_table} where wr_id = '{$row['wr_parent']}' ");

        $list[$i] = get_list($row, $board, $board_skin_url, G5_IS_MOBILE ? $board['bo_mobile_subject_len'] : $board['bo_subject_len']);
        if (strstr($sfl, 'subject')) {
            $list[$i]['subject'] = search_font($stx, $list[$i]['subject']);
        }
        $list[$i]['is_notice'] = false;
        $list_num = $total_count - ($page - 1) * $list_page_rows - $notice_count;
        $list[$i]['num'] = $list_num - $k;

        $i++;
        $k++;
    }
}
echo $list[0]['wr_4']."<br>".$list[1]['wr_4'];


echo $list[0]['wr_4']."<br>".$list[1]['wr_4'];
로 한번 출력해보았습니다.


280
280.2


DB처럼 제대로 나오고있습니다.

어디서 바뀌나 보려고 list.skin.php 제일위 1번재줄부터

echo $list[0]['wr_4']."<br>".$list[1]['wr_4'];

를 진행했는데

<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
include_once(G5_LIB_PATH.'/thumbnail.lib.php');
include_once("$board_skin_path/lib/skin.lib.php");
echo $list[0]['wr_4']."<br>".$list[1]['wr_4'];


280.2
280

이렇게나오는데


<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
include_once(G5_LIB_PATH.'/thumbnail.lib.php');
echo $list[0]['wr_4']."<br>".$list[1]['wr_4'];
include_once("$board_skin_path/lib/skin.lib.php");

4번째줄에 넣으니까

280
280.2

라고나옵니다.


include_once("$board_skin_path/lib/skin.lib.php");

이부분을 걸치면서 문제가 생기는거 같습니다.

include_once("$board_skin_path/lib/skin.lib.php");

를들어가니



if ($sst) {
    if($sst == "wr_1" || $sst == "wr_4"){
$sql_order = " order by {$sst}+0 {$sod} ";
}else{
$sql_order = " order by {$sst} {$sod} ";
}
}

여기부분이 이렇게되어있습니다

if ($sst) {
if($bo_table=="board_gallery"){
$sql_order = " order by {$sst} {$sod}, wr_4 {$sod}";
}else{
$sql_order = " order by {$sst} {$sod}";
}
}


로 바꾸니까 해결되었습니다.. 와 진자감사합니다 이거 며칠동안 찾아다녔는지요 덕분에 해결했습니다

카카오톡 smmysong 으로 추가해서 문의주시면 한번 접속해서 봐드릴게요.

금일 6시에는 퇴근합니다.. 그전까지만..

답변을 작성하시기 전에 로그인 해주세요.
전체 33
QA 내용 검색

회원로그인

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