첨부파일을 select로 가져오려고 합니다.
본문
<?
$sql = "select * from g5_write_15_board where wr_good = 0";
$row = sql_query($sql);
$aa = sql_fetch_array($row);
//echo $aa['wr_file'];
?>
이런 식으로 가려오려고 하는데..
첨부파일명이 안뜨고 1이라고 뜨네요..ㅠ
일반페이지에서 가려오려면 이 방법으로 하면 안되는 건가요?
답변 3
반복문 돌려주세요~
while($aa = sql_fetch_array($row)){
echo "<select~~~~";
echo "<option~~~~~".$aa['wr_file'] . "</option>";
echo "</select>";
}
get_file 함수가 있으니 함수 내용을 참고해서 작성하세요
// 게시글에 첨부된 파일을 얻는다. (배열로 반환)
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'];
$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'] = $row['bf_content'];
$file[$no]['content'] = get_text($row['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;
}
$files = get_file($bo_table, $wr_id);
print_r2($files);
echo $files['count'];