외부 변수값을 통한 최신글 정렬을 하고싶습니다. 정보
외부 변수값을 통한 최신글 정렬을 하고싶습니다.관련링크
첨부파일
본문
오류가 나는곳의 주소를 알려주시면 더 빠르고 정확하게 답변 받을 수 있습니다.
오류 주소 :
아래의 소스처럼
<table>
<? // =latest_rancategory("최신글스킨명", "보드명", 갯수, 글자수, "", "카테고리명");?>
<tr height="100%" valign="top"><td><?= latest_rancategory("elpis_gallery","mentolist2",49,"","", "상담가능"); ?></td></tr>
<tr height="100%" valign="top"><td><?= latest_rancategory("elpis_gallery","mentolist2",49,"","", "기도중"); ?></td></tr>
<tr height="100%" valign="top"><td><?= latest_rancategory("elpis_gallery","mentolist2",49,"","", "장기부재"); ?></td></tr>
</table>
카테고리명 별로 최신글을 노출하였습니다.
여기서 사용한 코드는
<?
// 최신글 카테고리 데이타를 랜덤으로 추출
function latest_rancategory ($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="", $category="") {
global $g4;
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/basic";
$list = array();
$sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
$board = sql_fetch($sql);
$tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
$sql = " select * from $tmp_write_table where ca_name = '$category' order by rand() desc limit 0, $rows ";
//explain($sql);
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++)
$list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
이 코드를 latest.lib2.php에 저장하여 include해서 사용하였더니 분류별로 잘 작동합니다.
구현하고 싶은 것은
카테고리명을 getState2.php의 외부페이지의 stateVar 값을 통해서 변경하고 싶은데요
<?= latest_rancategory("elpis_gallery","mentolist2",49,"","", "상담가능"); ?> 을
<?= latest_rancategory("elpis_gallery","mentolist2",49,"","", "1"); ?> 하여 stateVar =1 인 것을 정렬하고
<?= latest_rancategory("elpis_gallery","mentolist2",49,"","", "2"); ?> 하여 stateVar =2 인 것을 정렬하고
싶습니다.
한참 배우고 있는 상황이라 좀 어렵습니다~
혹 시도해보신분들있으시면 한 수 가르쳐 주세요~
몇일동안 밤세우고 있는데 방법을 못찾겠어요~ㅠㅠ
오류 주소 :
아래의 소스처럼
<table>
<? // =latest_rancategory("최신글스킨명", "보드명", 갯수, 글자수, "", "카테고리명");?>
<tr height="100%" valign="top"><td><?= latest_rancategory("elpis_gallery","mentolist2",49,"","", "상담가능"); ?></td></tr>
<tr height="100%" valign="top"><td><?= latest_rancategory("elpis_gallery","mentolist2",49,"","", "기도중"); ?></td></tr>
<tr height="100%" valign="top"><td><?= latest_rancategory("elpis_gallery","mentolist2",49,"","", "장기부재"); ?></td></tr>
</table>
카테고리명 별로 최신글을 노출하였습니다.
여기서 사용한 코드는
<?
// 최신글 카테고리 데이타를 랜덤으로 추출
function latest_rancategory ($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="", $category="") {
global $g4;
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/basic";
$list = array();
$sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
$board = sql_fetch($sql);
$tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
$sql = " select * from $tmp_write_table where ca_name = '$category' order by rand() desc limit 0, $rows ";
//explain($sql);
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++)
$list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
이 코드를 latest.lib2.php에 저장하여 include해서 사용하였더니 분류별로 잘 작동합니다.
구현하고 싶은 것은
카테고리명을 getState2.php의 외부페이지의 stateVar 값을 통해서 변경하고 싶은데요
<?= latest_rancategory("elpis_gallery","mentolist2",49,"","", "상담가능"); ?> 을
<?= latest_rancategory("elpis_gallery","mentolist2",49,"","", "1"); ?> 하여 stateVar =1 인 것을 정렬하고
<?= latest_rancategory("elpis_gallery","mentolist2",49,"","", "2"); ?> 하여 stateVar =2 인 것을 정렬하고
싶습니다.
한참 배우고 있는 상황이라 좀 어렵습니다~
혹 시도해보신분들있으시면 한 수 가르쳐 주세요~
몇일동안 밤세우고 있는데 방법을 못찾겠어요~ㅠㅠ
댓글 전체
정렬을 하신다고 하시면서
stateVar =1 인 것을 정렬하고 stateVar =2 인 것을 정렬하고 라뇨?
이 내용때문에 질문을 이해 할 수가 없네요..
정렬은 오름차순이나 내림차순으로 정렬해야 하는데..
stateVar =1 인 것을 정렬하고 stateVar =2 인 것을 정렬하고 라뇨?
이 내용때문에 질문을 이해 할 수가 없네요..
정렬은 오름차순이나 내림차순으로 정렬해야 하는데..