다시한번 질문드립니다

· 17년 전 · 1038 · 4
동내.jpg
자꾸 똑같은거 가지고 질문드려서 죄송해요ㅠㅠ
최신글에 일일알바면 일일알바 장기알바면 장기알바만 출력하고 싶은데 잘 안되네요 ㅠㅠ

latest.lib.php파일 아래와 같이 수정했습니다.

<?
if (!defined('_GNUBOARD_')) exit;

// 최신글 추출
function latest($skin_dir="", $bo_table, $rows=10, $subject_len=40, $option="and_wr_7='장기알바'")
{
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 ";
// 위의 코드 보다 속도가 빠름
if($options) $options="and wr_7='$options'";
$sql = " select * from $tmp_write_table where wr_is_comment = 0 $options order by wr_num 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("job_basic", "alba", 5, 70, "wr_7='장기알바'");?> 이렇게 하였습니다.
그런데도 모든알바가 출력이 되네요...
제가 수정한 게시판[jobcast00.zip] 파일과 최신글파일 [job_basic.zip]도 같이 첨부하여 올렸습니다.
시간되시는분은 게시판 소스봐주시겠어요? 짜집기로 만든것이라 게시판에 문제있는듯 싶습니다.
급한데 진전이 안되서 답답한 마음뿐이네요 ㅠㅠ

네이트 원격제어로 한번 봐주시면 정말정말정말정말 감사하겠습니다 ㅠㅠ id[hyunjin3233@yahoo.co.kr]입니다.

첨부파일

동내.jpg (38.5 KB)
0회 2008-10-23 22:41
jobcast00.zip (346.7 KB) 2회 2008-10-23 22:41
job_basic.zip (23.2 KB) 0회 2008-10-23 22:41
|

댓글 4개

우선
<?=latest("job_basic", "alba", 5, 70, "and wr_7='장기알바'");?>

option 철자 확인

wr_is_comment = 0 $options order by wr_num
==>
wr_is_comment = 0 $option order by wr_num
매번 답변주셔서 감사합니다^^

latest.lib.php파일 $options 을 모두 $option으로 아래와같이 수정하였습니다.

<?
if (!defined('_GNUBOARD_')) exit;

// 최신글 추출
function latest($skin_dir="", $bo_table, $rows=10, $subject_len=40, $option="and_wr_7='일일알바'")
{
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 ";
// 위의 코드 보다 속도가 빠름
if($option) $option="and wr_7='$option'";
$sql = " select * from $tmp_write_table where wr_is_comment = 0 $option order by wr_num 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("job_basic", "alba", 5, 70, "and wr_7='일일알바'");?> 로 출력하였으나 아래와 같은 에러 메세지가 나옵니다.

select * from g4_write_alba where wr_is_comment = 0 and wr_7='and_wr_7='일일알바'' order by wr_num limit 0, 5

1064 : 'SQL 구문에 오류가 있습니다.' 에러 같읍니다. ('일일알바'' order by wr_num limit 0, 5' 명령어 라인 1)

error file : /gnuboard4/test.php
여러 이유에서 가급적 원본 latest.lib.php 파일을 수정하지 말고 원본대로 유지하시는게 좋습니다.


아무튼 아래 내용을 아무이름.php 로 extend 폴더에 저장합니다.
이 아무이름.php 파일을 따로 인크루드 시킬필요는 없습니다.
그 이유는 common.php 405열쯤에 나와있으므로 참고하시구요.

<?
if (!defined('_GNUBOARD_')) exit;

function latest_option($skin_dir="", $bo_table, $rows=10, $subject_len=40, $option="")
{
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;

$option_sql = " wr_is_comment = 0 ";

$option_sql .= (!empty($option))?"and wr_7 = '".$option."'":""; //옵션이 있다면 `and wr_7 = '옵션내용'` 쿼리에 추가

$sql = " select * from $tmp_write_table where $option_sql order by wr_num limit 0, $rows ";

$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_option("job_basic", "alba", 5, 70, "장기알바");?>

-------------------------------------------------------------

추가로 입력단계에서(write.skin.php) 옵션값이 `장기알바` 이런식으로 들어가는것 보다는

<option value = "1">장기알바</option>
<option value = "2">단기알바</option>

처럼 간단하게 처리하고 호출은 다음처럼 해주면 좀더 나을겁니다.

<?=latest_option("job_basic", "alba", 5, 70, "1");//장기알바 최신글?>
<?=latest_option("job_basic", "alba", 5, 70, "2");//단기알바 최신글?>

테스트 못해봤습니다.^^
답변 감사합니다^^
댓글을 작성하시려면 로그인이 필요합니다.

그누4 질문답변

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

+
제목 글쓴이 날짜 조회
17년 전 조회 873
17년 전 조회 1,622
17년 전 조회 900
17년 전 조회 1,073
17년 전 조회 1,157
17년 전 조회 926
17년 전 조회 1,026
17년 전 조회 2,863
17년 전 조회 995
17년 전 조회 1,039
17년 전 조회 764
17년 전 조회 746
17년 전 조회 818
17년 전 조회 705
17년 전 조회 858
17년 전 조회 802
17년 전 조회 969
17년 전 조회 793
17년 전 조회 756
17년 전 조회 776