mysql_fetch_array 함수 > 그누4 질문답변

그누4 질문답변

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

mysql_fetch_array 함수 정보

mysql_fetch_array 함수

본문

mysql_fetch_array 함수로 $test 변수에 배열로 저장할려고 하는데
where 조건 맞는 녀석 전부 배열로 삼아야되는데
어떻게해요 ??

    $sql = mysql_query("select bf_file from g4_board_file WHERE bo_table = '$bo_table' and wr_id = '$wr_id'");
$files = mysql_fetch_array($sql);

하면 files[0] 에만 맨처음거 저장되고 끝나버리네요 ;;
where조건에 맞는 거 전부 배열로 만들어야되는데 ;;
  • 복사

댓글 전체

그누보드에서 사용하는 함수로 예를 들자면

$sql = "select bf_file from g4_board_file WHERE bo_table = '$bo_table' and wr_id = '$wr_id'";
$result = sql_query($sql);
while ($row = sql_fetch_array($result)) {
$files[] = $row;
}


원하시는 기능을 통밥으로 이야기 해드리자면
$files = get_file($bo_table, $wr_id);



그누보드 기본 함수에


// 게시글에 첨부된 파일을 얻는다. (배열로 반환)
function get_file($bo_table, $wr_id)
{
    global $g4, $qstr;

    $file["count"] = 0;
    $sql = " select * from $g4[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] = "./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] = "$g4[path]/data/file/$bo_table";
        //$file[$no][size] = get_filesize("{$file[$no][path]}/$row[bf_file]");
        $file[$no][size] = get_filesize($row[bf_filesize]);
        //$file[$no][datetime] = date("Y-m-d H:i:s", @filemtime("$g4[path]/data/file/$bo_table/$row[bf_file]"));
        $file[$no][datetime] = $row[bf_datetime];
        $file[$no][source] = $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];
        // prosper 님 제안
        //$file[$no][imgsize] = @getimagesize("{$file[$no][path]}/$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;
}

이런게 있지요
© SIRSOFT
현재 페이지 제일 처음으로