최신글에서 이미지 추출하는 SQL 문을 아시는 분 있나요? 정보
최신글에서 이미지 추출하는 SQL 문을 아시는 분 있나요?
본문
http://www.sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=1774
위 주소에서 원하는 게시판을 모아서 최신글을 추출하는 코드를 적용시켜봤는데요.
이미지가 모두 엑박으로 나옵니다.
$list[$i][href] = "$g4[bbs_path]/board.php?bo_table=$row[bo_table]&wr_id=$row2[wr_id]";
$list[$i][wr_subject] = cut_str($row2[wr_subject], $subject_len, "…");
저런 식으로 링크, 제목등을 수동으로 지정해줘야 하던데 이미지는 어떻게 해줘야 할까요?
"g4_write_테이블명" <- 여기서 필드를 봐도 파일이나 이미지에 관련된 필드는 없더군요.
치에님이 알려주신 방법으로 위 페이지의 아래 부분을....
$row2 = sql_fetch(" select wr_subject,wr_id from $tmp_write_table where wr_id = '$row[wr_id]' ");
$list[$i] = $row2;
$list[$i][bo_table] = $row[bo_table];
$list[$i][href] = "$g4[bbs_path]/board.php?bo_table=$row[bo_table]&wr_id=$row2[wr_id]";
$list[$i][wr_subject] = cut_str($row2[wr_subject], $subject_len, "…");
아래와 같이 고치면....
$row2 = sql_fetch(" select * from $tmp_write_table where wr_id = '$row[wr_id]' ");
$list[$i] = get_list($row2, $board, $latest_skin_path, $subject_len);
$list[$i][bo_table] = $row[bo_table];
$list[$i][href] = "$g4[bbs_path]/board.php?bo_table=$row[bo_table]&wr_id=$row2[wr_id]";
제목같은건 따로 지정해 주지 않아도 표시가 되더군요.
하지만 이미지는 여전히 엑박으로 표시되고 있습니다. 이미지를 따로 추출해줘야 하나요?
기존 최신글 코드를 봐도 따로 이미지를 추출한다거나 하는건 없는데 말이죠.. 으으으으....
도와주세요오~~@.@
위 주소에서 원하는 게시판을 모아서 최신글을 추출하는 코드를 적용시켜봤는데요.
이미지가 모두 엑박으로 나옵니다.
$list[$i][href] = "$g4[bbs_path]/board.php?bo_table=$row[bo_table]&wr_id=$row2[wr_id]";
$list[$i][wr_subject] = cut_str($row2[wr_subject], $subject_len, "…");
저런 식으로 링크, 제목등을 수동으로 지정해줘야 하던데 이미지는 어떻게 해줘야 할까요?
"g4_write_테이블명" <- 여기서 필드를 봐도 파일이나 이미지에 관련된 필드는 없더군요.
치에님이 알려주신 방법으로 위 페이지의 아래 부분을....
$row2 = sql_fetch(" select wr_subject,wr_id from $tmp_write_table where wr_id = '$row[wr_id]' ");
$list[$i] = $row2;
$list[$i][bo_table] = $row[bo_table];
$list[$i][href] = "$g4[bbs_path]/board.php?bo_table=$row[bo_table]&wr_id=$row2[wr_id]";
$list[$i][wr_subject] = cut_str($row2[wr_subject], $subject_len, "…");
아래와 같이 고치면....
$row2 = sql_fetch(" select * from $tmp_write_table where wr_id = '$row[wr_id]' ");
$list[$i] = get_list($row2, $board, $latest_skin_path, $subject_len);
$list[$i][bo_table] = $row[bo_table];
$list[$i][href] = "$g4[bbs_path]/board.php?bo_table=$row[bo_table]&wr_id=$row2[wr_id]";
제목같은건 따로 지정해 주지 않아도 표시가 되더군요.
하지만 이미지는 여전히 엑박으로 표시되고 있습니다. 이미지를 따로 추출해줘야 하나요?
기존 최신글 코드를 봐도 따로 이미지를 추출한다거나 하는건 없는데 말이죠.. 으으으으....
도와주세요오~~@.@
댓글 전체

일반적으로 그냥 DB에서 파일링크 뽑아와서 출력해도 되긴 하지만 트래픽을 많이 잡아먹겠죠~
<?
$cols = 90; // 이미지 가로갯수 // 이미지 세로 갯수는 메인에서 지정(총 이미지 수)
$image_h = 2; // 이미지 상하 간격
$col_width = (int)(99 / $cols);
$img_width = 340; //썸네일 가로길이
$img_height = 230; //썸네일 세로길이
$img_quality = 60; //퀼리티 100이하로 설정
if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.");
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb340'; //썸네일 이미지 생성 디렉토리
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
?>
<? for ($i=0; $i<count($list); $i++) {
if ($i>0 && $i%$cols==0) { echo "<td colspan='$cols' height='$image_h'></td><tr>"; }
$img = "<img src='$g4_path/img/noimage.gif' border=1 width='$img_width' height='$img_height' title='이미지 없음' align=left style='margin-right:5px; border:1 #222222 solid;'>";
$thumb = $thumb_path.'/thumb_image';//.$list[$i][wr_id];
// 썸네일 이미지가 존재하지 않는다면
if (!file_exists($thumb)) {
$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
// 업로드된 파일이 이미지라면
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file)) {
$size = getimagesize($file);
if ($size[2] == 1)
$src = imagecreatefromgif($file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$src = imagecreatefrompng($file);
else
break;
$rate = $img_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagepng($dst, $thumb_path.'/thumb_image', $img_quality);
chmod($thumb_path.'/thumb_image', 0606);
}
}
$img = "$g4[path]/data/file/$bo_table/".urlencode($list[$i][file][0][file]);
$img = "<img src='$img' border=1 align=left style='margin-right:5px; border:1 #222222 solid;' height='$img_height' width='$img_width'>";
?>
어느 최신글 추출에 있던 소스 인데 참고 하시면 될것 같습니다.
GD를 이용하여 게시판 이미지를 썸네일로 변경시켜서 불러오게 됩니다
한번 해독하고 사용하세여^^
<?
$cols = 90; // 이미지 가로갯수 // 이미지 세로 갯수는 메인에서 지정(총 이미지 수)
$image_h = 2; // 이미지 상하 간격
$col_width = (int)(99 / $cols);
$img_width = 340; //썸네일 가로길이
$img_height = 230; //썸네일 세로길이
$img_quality = 60; //퀼리티 100이하로 설정
if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.");
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb340'; //썸네일 이미지 생성 디렉토리
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
?>
<? for ($i=0; $i<count($list); $i++) {
if ($i>0 && $i%$cols==0) { echo "<td colspan='$cols' height='$image_h'></td><tr>"; }
$img = "<img src='$g4_path/img/noimage.gif' border=1 width='$img_width' height='$img_height' title='이미지 없음' align=left style='margin-right:5px; border:1 #222222 solid;'>";
$thumb = $thumb_path.'/thumb_image';//.$list[$i][wr_id];
// 썸네일 이미지가 존재하지 않는다면
if (!file_exists($thumb)) {
$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
// 업로드된 파일이 이미지라면
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file)) {
$size = getimagesize($file);
if ($size[2] == 1)
$src = imagecreatefromgif($file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$src = imagecreatefrompng($file);
else
break;
$rate = $img_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagepng($dst, $thumb_path.'/thumb_image', $img_quality);
chmod($thumb_path.'/thumb_image', 0606);
}
}
$img = "$g4[path]/data/file/$bo_table/".urlencode($list[$i][file][0][file]);
$img = "<img src='$img' border=1 align=left style='margin-right:5px; border:1 #222222 solid;' height='$img_height' width='$img_width'>";
?>
어느 최신글 추출에 있던 소스 인데 참고 하시면 될것 같습니다.
GD를 이용하여 게시판 이미지를 썸네일로 변경시켜서 불러오게 됩니다
한번 해독하고 사용하세여^^

저 코드는 최신글 스킨의 코드가 아닌가요?
제가 쓰고 있는 최신글 스킨의 코드에서는
<?
$image = urlencode($list[$i][file][0][file]); // 첫번째 파일이 이미지라면
if (preg_match("/\.(gif|jpg|png)$/i", $image) && file_exists("$g4[path]/data/file/$bo_table/$image")) {
echo "<a href='{$list[$i][href]}'><img src='$g4[path]/data/file/$bo_table/$image' width='{$img_w}' height='{$img_h}' border='0'></a>";
} else {
echo "<a href='{$list[$i][href]}'><img src='$latest_skin_path/img/no_img.gif' width='{$img_w}' height='{$img_h}' border='0'></a>";
}
?>
저런식으로 이미지를 추출하는 코드가 있습니다.
일반 최신글 함수를 사용하여 출력을 하면 이미지까지 잘 출력이 됩니다.
문제는 질문에 적어논 페이지의 최신글 함수를 사용하면 이미지가 출력이 안된다는 것이죠..
$list[$i][file][0][file] 이 부분에 대한 내용을 sql로 뽑아서 적용시켜야 되는게 아닌가 하기도 하고 혼란스럽네요..에궤구..
제가 쓰고 있는 최신글 스킨의 코드에서는
<?
$image = urlencode($list[$i][file][0][file]); // 첫번째 파일이 이미지라면
if (preg_match("/\.(gif|jpg|png)$/i", $image) && file_exists("$g4[path]/data/file/$bo_table/$image")) {
echo "<a href='{$list[$i][href]}'><img src='$g4[path]/data/file/$bo_table/$image' width='{$img_w}' height='{$img_h}' border='0'></a>";
} else {
echo "<a href='{$list[$i][href]}'><img src='$latest_skin_path/img/no_img.gif' width='{$img_w}' height='{$img_h}' border='0'></a>";
}
?>
저런식으로 이미지를 추출하는 코드가 있습니다.
일반 최신글 함수를 사용하여 출력을 하면 이미지까지 잘 출력이 됩니다.
문제는 질문에 적어논 페이지의 최신글 함수를 사용하면 이미지가 출력이 안된다는 것이죠..
$list[$i][file][0][file] 이 부분에 대한 내용을 sql로 뽑아서 적용시켜야 되는게 아닌가 하기도 하고 혼란스럽네요..에궤구..

아항~_~;; 잘못 이해했네여=ㅁ=;;
$row2 = sql_fetch(" select wr_subject,wr_id from $tmp_write_table where wr_id = '$row[wr_id]' ");
요기는 제목이랑 글ID 불러오는 쿼리구요...
g4_board_file 로 보드값이랑 wr_id값 날려서 다시 뽑으셔야해요~_~;;
$row2 = sql_fetch(" select wr_subject,wr_id from $tmp_write_table where wr_id = '$row[wr_id]' ");
요기는 제목이랑 글ID 불러오는 쿼리구요...
g4_board_file 로 보드값이랑 wr_id값 날려서 다시 뽑으셔야해요~_~;;

기본 최신글 함수에서는 어떻게 이미지를 추출했는지 이거원.. 아리송송 알쏭달쏭 알리바바네요..으아아악