쿼리 관련 질문 정보
쿼리 관련 질문
본문
현제 6개의 게시물이 존재한다고 했을때,
보토 아래처럼 나옵니다.
6. ㅂ
5. ㅁ
4. ㄹ
3. ㄷ
2. ㄴ
1. ㄱ
근데 5개라고 가정하면
6. ㅂ
5. ㅁ
4. ㄹ
3. ㄷ
2. ㄴ
위처럼 나오는데요 (정상적인)
최근 게시물 쿼리가
$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_num limit 0, $rows ";
요렇게 되어있는데요.
desc를 추가하고 5개를 뽑으면
1. ㄱ
2. ㄴ
3. ㄷ
4. ㄹ
5. ㅁ
이렇게 나오거든요.
5개를 뽑을때
2. ㄴ
3. ㄷ
4. ㄹ
5. ㅁ
6. ㅂ
이렇게 나오게 뽑을려면 어떻게 하죠?
최신글일수록 젤 뒤로 나오게 할려고 desc 줬는데, 이후에는 모르겠습니다.
쿼리는 문외안이라 도움을 부탁드립니다.
이해하셧는지 모르겠네요.
$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_num desc limit 1, $rows ";
현제 이렇게 해놨어요. 임시로
댓글 전체

따라했는데, limits 6을 해버리면, 게시물 숫자에 따라 나오고 안나오고 하던데 이건 왜그렇죠?
게시물이 늘어나면 limits도 늘어나야 될거같아요.
게시물이 늘어나면 limits도 늘어나야 될거같아요.

아니면 이런 방법은 없나요?
sql 쿼리에서 일단
$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_num limit 0, $rows ";
요렇게 하면 ($rows는 5개)
6. ㅂ
5. ㅁ
4. ㄹ
3. ㄷ
2. ㄴ
게 나왔다치고 이것을 2번부터 나오게 소스를 꺼꿀로 뒤집으면 될것같은데,
쿼리문 손안대고 아래 소스에서 수정하는 방법은 없을까요?
$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;
sql 쿼리에서 일단
$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_num limit 0, $rows ";
요렇게 하면 ($rows는 5개)
6. ㅂ
5. ㅁ
4. ㄹ
3. ㄷ
2. ㄴ
게 나왔다치고 이것을 2번부터 나오게 소스를 꺼꿀로 뒤집으면 될것같은데,
쿼리문 손안대고 아래 소스에서 수정하는 방법은 없을까요?
$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;

아 쿼리는 신기하네요. 마음대로 이것저것 바꿨다가 막 성공했어요.
// 최신글 추출 (typing)
function latest_typing($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="")
{
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 wr_is_comment = 0 order by wr_id desc limit 0, $rows ";
// 위의 코드 보다 속도가 빠름
$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_num limit 0, $rows ";
//explain($sql);
//explain($sql);
$result = sql_query($sql);
for ($i=4; $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;
}
이렇게 했더니 최근게시물 5개를 거꿀로 불러올 수 있네요.
나스카님 감사합니다. 링크가 도움이 컸어요.
// 최신글 추출 (typing)
function latest_typing($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="")
{
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 wr_is_comment = 0 order by wr_id desc limit 0, $rows ";
// 위의 코드 보다 속도가 빠름
$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_num limit 0, $rows ";
//explain($sql);
//explain($sql);
$result = sql_query($sql);
for ($i=4; $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;
}
이렇게 했더니 최근게시물 5개를 거꿀로 불러올 수 있네요.
나스카님 감사합니다. 링크가 도움이 컸어요.