사이트주소는 여기입니다.
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입니다.

이상태에서 아래 fov 정렬 두개는 잘되는데
나머지 mag와 wd , image 정렬 3개는 2순위 정렬이되지않고 있습니다.
2순위는 WD정렬입니다.
보시다시피 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에다가 출력하니까

???
wr_1에관해서 wr_4가 제대로 정렬이 오름차순으로 진행되는것을확인할수가 있습니다.
그런데 홈페이지에서는 이것이 제대로 이루어지지않습니다
왜 이런현상이 일어나는걸까요 ?
답변 2개 / 댓글 26개
sql_fetch해서 나온 result를
var_dump로 찍어보세요
가져온 순서도 정렬이 되서 가져와지는지
답변에 대한 댓글 24개
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) "" }
$list[$i] = get_list($row, $board, $board_skin_url, G5_IS_MOBILE ? $board['bo_mobile_subject_len'] : $board['bo_subject_len']);
여기가 실행되면서 꼬이는게 아닐까 싶네요
이부분도 하나씩 까보면서 해결해보셔야될거같아요
이부분은 삭제해도 변동사항이 없었습니다. 아마 검색이아니라서 이부분은 진행이안되는거같습니다.
그래서
$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"
그대로 나왔습니다
$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']}' ");
이부분을 추가를 어떻게 해야하는건가요 ?
// 게시물 정보($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'].'&sca='.urlencode($list['ca_name']);
$list['href'] = G5_BBS_URL.'/board.php?bo_table='.$board['bo_table'].'&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'].'&wr_id='.$list['wr_id'].'&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로 바꾼뒤에 소스 어느걸 추가하면될까요 ?
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처럼 안나왔습니다.
$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처럼 제대로 나오고있습니다.
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");
이부분을 걸치면서 문제가 생기는거 같습니다.
를들어가니
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시에는 퇴근합니다.. 그전까지만..
답변을 작성하려면 로그인이 필요합니다.

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)
라고나옵니다