정렬 질문드립니다 ㅠㅠ
본문
현재 정렬 기준이 금융기관 기준 A,B,C 순인데요... 실금융기관 기준 가나다순으로 바꾸려면 어찌해야할까요??
<?php
$sub_menu = '600210';
include_once('./_common.php');
auth_check($auth[$sub_menu], "r");
$token = get_token();
$g5['title'] = '금융기관관리';
include_once (G5_ADMIN_PATH.'/admin.head.php');
//if(!$cat) $cat = 1;
$qstr .= "&cat={$cat}";
$tbl = "loan";
$colspan = 10;
$sql = "SELECT * FROM `".$tbl."` WHERE 1 ";
if($cat){
$sql .= " AND `flag` = '".$cat."' ";
}
if($sfl && $stx) $sql .= " AND INSTR(`".$sfl."`, '".$stx."') ";
$res = sql_query($sql);
$total_count = mysql_num_rows($res);
$rows = 20;
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
if(!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함
if(!$sst) {
$sst = "nm, seq";
$sod = "desc";
}
$sql.=" ORDER BY ".$sst." ".$sod." LIMIT $from_record, $rows ";
$result = sql_query($sql);
//echo $sql;
$listall = "<a href='$_SERVER[PHP_SELF]' class=tt>전체</a>";
?>
<div class="local_ov01 local_ov">전체 <?php echo $total_count; ?>건</div>
<form name="fsearch" id="fsearch" class="local_sch01 local_sch" method="get">
<select name="cat" class="sel" onChange="location.href='?cat='+this.value;">
<?php
echo '<option value="0">전체</option>' . "\n";
foreach ($flag_array as $key => $val)
if(is_bool(strpos($val, '신용')) && $val!='1:1간편상담')
echo '<option value="' . $key . '"' . ($key==$cat ? ' selected':null) . '>' . $val . '</option>' . "\n";
?>
</select>
<label for="sfl" class="sound_only">검색대상</label>
<select name="sfl" id="sfl" class="sel">
<option value="nm"<?php echo get_selected($_GET['sfl'], "nm", true); ?>>금융기관명</option>
<option value="fnm"<?php echo get_selected($_GET['sfl'], "fnm", true); ?>>실금융기관명</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" required class="required frm_input">
<input type="submit" value="검색" class="btn_submit">
</form>
<div class="btn_add01 btn_add">
<a href="./_loan.write.php" id="add">추가</a>
</div>
<form name="loanlist" id="loanlist" action="./_loan.list.proc.php" onsubmit="return loanlist_submit(this);" method="post">
<input type=hidden name="page" value="<?=$page?>">
<input type=hidden name="sfl" value="<?=$sfl?>">
<input type=hidden name="stx"value="<?=$stx?>">
<input type=hidden name="sst"value="<?=$sst?>">
<input type=hidden name="sod" value="<?=$sod?>">
<input type=hidden name="cat" value="<?=$cat?>">
<input type=hidden name="mode" value="">
<div class="tbl_head01 tbl_wrap">
<table>
<caption><?php echo $g5['title']; ?> 목록</caption>
<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">구분</th>
<th scope="col">선/후순위</th>
<th scope="col">금융기관</th>
<th scope="col">실금융기관명</th>
<th scope="col" style="width:100px;">신용등급</th>
<th scope="col">LTV</th>
<th scope="col">DTI</th>
<th scope="col">DSR</th>
<th scope="col" style="width:200px;">금리</th>
<!--th scope="col">대출한도</th-->
<th scope="col">보기</th>
</tr>
</thead>
<tbody>
<?
for($i=0;$row=sql_fetch_array($result);$i++){
$one_update = '<a href="./_loan.write.php?seq='.$row['seq'].'&'.$qstr.'">수정</a>';
?>
<tr class="<?php echo $bg; ?>">
<td class="td_chk">
<label for="chk_<?php echo $i; ?>" class="sound_only"><?php echo get_text($row['fname']) ?></label>
<input type="hidden" name="seq[<?php echo $i ?>]" value="<?php echo $row['seq'] ?>" id="seq_<?php echo $i ?>">
<input type="checkbox" name="chk[]" value="<?php echo $i ?>" id="chk_<?php echo $i ?>">
</td>
<td class="td_tel"><select name="flag[]" required title="구분" class="sel">
<?php
foreach ($flag_array as $key => $val)
if(is_bool(strpos($val, '신용')) && $val!='1:1간편상담')
echo '<option value="' . $key . '"' . ($key==$row['flag'] ? ' selected':null) . '>' . $val . '</option>' . "\n";
?>
</select></td>
<td class="td_test"><select name="rank[]" class="sel">
<option value="선순위"<?=($row['rank']!='후순위' ? ' selected':null)?>>선순위</option>
<option value="후순위"<?=($row['rank']=='후순위' ? ' selected':null)?>>후순위</option>
</select></td>
<td class="td_test"><input type="text" name="nm[]" class="frm_input" size="10" maxlength="20" value="<?=$row['nm']?>"></td>
<td class="td_test"><input type="text" name="fnm[]" class="frm_input" size="10" maxlength="20" value="<?=$row['fnm']?>"></td>
<td class="td_test"><input type="text" name="grade[]" class="frm_input onlyNum" size="2" maxlength="2" value="<?=$row['grade']?>"> 등급▲</td>
<td class="td_test"><input type="text" name="ltv[]" class="frm_input onlyNum" size="3" maxlength="3" value="<?=$row['ltv']?>">%</td>
<td class="td_test"><select name="dti[]" class="sel">
<option value="무관"<?=($row['dti']!='일부적용'&&$row['dti']!='적용' ? ' selected':null)?>>무관</option>
<option value="일부적용"<?=($row['dti']=='일부적용' ? ' selected':null)?>>일부적용</option>
<option value="적용"<?=($row['dti']=='적용' ? ' selected':null)?>>적용</option>
</select></td>
<td class="td_test"><select name="dsr[]" class="sel">
<option value="무관"<?=($row['dsr']!='일부적용'&&$row['dsr']!='적용' ? ' selected':null)?>>무관</option>
<option value="일부적용"<?=($row['dsr']=='일부적용' ? ' selected':null)?>>일부적용</option>
<option value="적용"<?=($row['dsr']=='적용' ? ' selected':null)?>>적용</option>
</select></td>
<td class="td_odrnum2"><select name="fixed[]" class="sel">
<option value="변동"<?=($row['fixed']!='고정' ? ' selected':null)?>>변동</option>
<option value="고정"<?=($row['fixed']=='고정' ? ' selected':null)?>>고정</option>
</select> <input type="text" name="interest[]" class="frm_input float" size="5" maxlength="6" value="<?=($row['interest']>0 ? floatval($row['interest']):null)?>">%~<input type="text" name="interest2[]" class="frm_input float" size="5" maxlength="6" value="<?=($row['interest2']>0 ? floatval($row['interest2']):null)?>">%</td>
<!--td class="td_tel"><input type="text" name="limited[]" class="frm_input onlyNum" size="6" maxlength="6" value="<?=$row['limited']?>"> 만원</td-->
<td class="td_mngsmall">
<?php echo $one_update ?>
</td>
</tr>
<?
}
if(!$total_count)
echo "<tr><td colspan=\"".$colspan."\" class=\"empty_table\">자료가 없습니다.</td></tr>";
?>
</table>
</div>
<div class="btn_list01 btn_list">
<input type="submit" name="act_button" value="선택수정" onclick="document.pressed=this.value">
<input type="submit" name="act_button" value="선택삭제" onclick="document.pressed=this.value">
</div>
</form>
<?php echo get_paging(G5_IS_MOBILE ? $config['cf_mobile_pages'] : 20, $page, $total_page, '?'.$qstr.'&page='); ?>
<script>
function loanlist_submit(f)
{
if (!is_checked("chk[]")) {
alert(document.pressed+" 하실 항목을 하나 이상 선택하세요.");
return false;
}
if(document.pressed == "선택삭제") {
if(!confirm("선택한 자료를 정말 삭제하시겠습니까?")) {
return false;
}
}
return true;
}
$(document).ready(function() {
$('.onlyNum,.money,.float').css('ime-mode', 'disabled');
$('.onlyNum,.money').live('keypress', function(e){
return ( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)) ? false : true ;
});
$('.float').live('keypress', function(e){
return ( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57) && e.which!=46) ? false : true ;
});
});
</script>
<?
include_once("./admin.tail.php");
?>
답변 1
if(!$sst) {
$sst = "nm, seq";
$sod = "desc";
}
$sst = "nm, seq";
=> $sst = "fnm, seq";
=> 이렇게 변경하시면 됩니다.