카테고리 직접생성 쿼리 질문드려요
본문
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
if($board['bo_use_category']) {
if($ca_name=="etc" && $ca_name_user){
$category=explode("|",$board['bo_category_list']);
for($i=0;$i<count($category);$i++){
if($category[$i]==$ca_name_user){
$c="no";
sql_query("update {$write_table} set ca_name = '{$ca_name_user}' where wr_id='{$wr_id}'");
break;
}
}
if(!$c){
$new_cate=$board['bo_category_list']."|".$ca_name_user;
$sort_cate=explode("|",$new_cate);
sort($sort_cate);
$cate="";
$cutnum=count($sort_cate) -1;
for($i=0;$i<count($sort_cate);$i++){
if($i==$cutnum){
$cate .= $sort_cate[$i];
}
else{
$cate.= $sort_cate[$i]."|";
}
}
sql_query("update {$g5['board_table']} set bo_category_list = '{$cate}' where bo_table='{$bo_table}'");
sql_query("update {$write_table} set ca_name = '{$ca_name_user}' where wr_id='{$wr_id}'");
}
}
}
?>
카테고리 직접만들수 있는 쿼리인데요
여기에서 카테고리를 사용자가 직접생성하면
숫자가 낮은 것부터 카테고리들이 정렬이 되는데 높은것 부터 정렬되게 하려면 어떻게 바꿔줘야 할까요??
예>
2011
2012
2013
이렇게 정렬되는것이
2013
2012
2011
이렇게요
답변 1
$sort_cate=explode("|",$new_cate);
sort($sort_cate);
$cate="";
sort 를 rsort 로 변경하시면 역순으로 정렬가능합니다.
!-->