다른 테이블에 있는 그림파일 가져오기는 어떻게 해야할까요?
본문
제목 그대로 다른 게시판 테이블에 있는 그림파일을 가지고 오고 싶은데 어떤 방법이 있을까요?
A게시판 게시물에 첨부된 이미지 파일을
B게시판 글쓰기 페이지에 표현하려고 합니다.
혹시 참조할 만한 내용이 있을까요?
게시물을 찾아보니 flypla님의 질문에 작은별님이 알려주신 팁이 있어 적용을 해보려하는데... 어딜 수정을 해야될지 모르겠네요...
참고로
A게시판의 테이블명은 aaa 이고
wr_id 값은 A게시판에서 Get방식으로 wr_2에 저장하였습니다.
<?
function get_file($bo_table, $wr_id)
{
global $g5, $qstr;
$file['count'] = 0;
$sql = " select * from {$g5['board_file_table']} where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no ";
$result = sql_query($sql);
while ($row = sql_fetch_array($result))
{
$no = $row['bf_no'];
$bf_content = $row['bf_content'] ? html_purifier($row['bf_content']) : '';
$file[$no]['href'] = G5_BBS_URL."/download.php?bo_table=$bo_table&wr_id=$wr_id&no=$no" . $qstr;
$file[$no]['download'] = $row['bf_download'];
// 4.00.11 - 파일 path 추가
$file[$no]['path'] = G5_DATA_URL.'/file/'.$bo_table;
$file[$no]['size'] = get_filesize($row['bf_filesize']);
$file[$no]['datetime'] = $row['bf_datetime'];
$file[$no]['source'] = addslashes($row['bf_source']);
$file[$no]['bf_content'] = $bf_content;
$file[$no]['content'] = get_text($bf_content);
//$file[$no]['view'] = view_file_link($row['bf_file'], $file[$no]['content']);
$file[$no]['view'] = view_file_link($row['bf_file'], $row['bf_width'], $row['bf_height'], $file[$no]['content']);
$file[$no]['file'] = $row['bf_file'];
$file[$no]['image_width'] = $row['bf_width'] ? $row['bf_width'] : 640;
$file[$no]['image_height'] = $row['bf_height'] ? $row['bf_height'] : 480;
$file[$no]['image_type'] = $row['bf_type'];
$file['count']++;
}
return $file;
}
$file1_src = '<img src="'.$file[0]['path'].'/'.$file[0]['file'].'" width="135">';
?>
<?php echo $file1_src; ?>
답변 3
* [B 게시판 스킨 폴더]/write.skin.php 상단에 추가
(get_file() 함수는 그누보드에서 이미 정의되어 있기 때문에 호출만 하면 됩니다.)
<?php
$file = get_file('aaa', $wr_2);
$img = '<img src="'.$file[0]['path'].'/'.$file[0]['file'].'" width="280" height="300">';
echo $img;
?>
※ PHP 함수 정의 방법과 호출 방법을 익히시는 게 좋을 것 같습니다. https://m.blog.naver.com/PostView.nhn?blogId=diceworld&logNo=220200148145
wr_id 값은 A게시판에서 Get방식으로 wr_2에 저장하였습니다.<--이게 무슨 말인가요?
B게시판에서 글쓰기할 때 A게시판에서 어떤 조건으로 이미지를 가져오는지
이미지 첨부가 여러개이면 어떻게 하는 것인지
게시판 글쓰기 페이지에 표현하려고 합니다.<--이게 무슨 말인지
남이 알아먹게 질문이 상세해야 됩니다