외부 변수값을 통한 최신글 정렬을 하고싶습니다.

오류가 나는곳의 주소를 알려주시면 더 빠르고 정확하게 답변 받을 수 있습니다.

오류 주소 :

아래의 소스처럼

<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 인 것을 정렬하고
싶습니다.

한참 배우고 있는 상황이라 좀 어렵습니다~

혹 시도해보신분들있으시면 한 수 가르쳐 주세요~

몇일동안 밤세우고 있는데 방법을 못찾겠어요~ㅠㅠ

첨부파일

getState2.php (1.1 KB) 0회 2013-11-16 02:28
latest.lib2.php (2.1 KB) 2회 2013-11-16 02:28
default_latest.php (7.5 KB) 1회 2013-11-16 02:28
|

댓글 1개

정렬을 하신다고 하시면서
stateVar =1 인 것을 정렬하고 stateVar =2 인 것을 정렬하고 라뇨?

이 내용때문에 질문을 이해 할 수가 없네요..

정렬은 오름차순이나 내림차순으로 정렬해야 하는데..
댓글을 작성하시려면 로그인이 필요합니다.

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기 기존 게시물은 열람만 가능합니다.

+
제목 글쓴이 날짜 조회
12년 전 조회 2,187
12년 전 조회 1,896
12년 전 조회 3,597
12년 전 조회 2,551
12년 전 조회 1,433
12년 전 조회 1,738
12년 전 조회 1,753
12년 전 조회 1,754
12년 전 조회 3,022
12년 전 조회 1,789
12년 전 조회 1,747
12년 전 조회 1,224
12년 전 조회 1,153
12년 전 조회 1,832
12년 전 조회 2,806
12년 전 조회 1,941
12년 전 조회 1,652
12년 전 조회 1,979
12년 전 조회 3,389
12년 전 조회 2,786