혹시 이런게 가능할까요? 여러 갤러리 게시판 내용이 하나의 게시판에서?

혹시 이런게 가능할까요? 여러 갤러리 게시판 내용이 하나의 게시판에서?

QA

혹시 이런게 가능할까요? 여러 갤러리 게시판 내용이 하나의 게시판에서?

답변 3

본문

안녕하세요.

 

갤러리 게시판이 1, 2, 3, 4 총 4개가 있습니다.

1은 가족사진

2는 동호회사진

3은 동물사진

4는 나무사진

 

뭐 이렇게 이용하고 있다고 가정했을 때,

 

저 4개 게시판의 사진들이 모두 별도 하나의 게시판에서 볼 수 있게 가능할까요?

이 질문에 댓글 쓰기 :

답변 3

가능한 부분이며, 추가로 페이지(코딩)를 따로 만드셔야 합니다~

 

참고)

 

 

<?php
include_once('./_common.php'); // 그누보드 공통 파일 포함

// 각 갤러리 게시판의 테이블 이름
$tables = ['gallery1', 'gallery2', 'gallery3', 'gallery4'];

$all_photos = [];

// 각 게시판의 데이터를 가져옵니다
foreach ($tables as $table) {
    $sql = "SELECT * FROM {$g5['write_prefix']}{$table} ORDER BY wr_id DESC";
    $result = sql_query($sql);
    while ($row = sql_fetch_array($result)) {
        $all_photos[] = $row;
    }
}

// wr_datetime 기준으로 내림차순 정렬
usort($all_photos, function($a, $b) {
    return strtotime($b['wr_datetime']) - strtotime($a['wr_datetime']);
});
?>

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <title>통합 갤러리</title>
    <link rel="stylesheet" href="<?php echo G5_THEME_URL ?>/style.css">
</head>
<body>
    <div id="gallery_all">
        <h1>통합 갤러리</h1>
        <div class="gallery_wrap">
            <?php foreach ($all_photos as $photo) { ?>
                <div class="gallery_item">
                    <a href="<?php echo get_view_href($photo['bo_table'], $photo['wr_id']) ?>">
                        <img src="<?php echo G5_DATA_URL ?>/file/<?php echo $photo['bo_table'] ?>/<?php echo $photo['bf_file'] ?>" alt="<?php echo $photo['wr_subject'] ?>">
                        <p><?php echo $photo['wr_subject'] ?></p>
                    </a>
                </div>
            <?php } ?>
        </div>
    </div>
</body>
</html>

<style>

.myimg{width:300px;}

</style>

<?php

$tableStr="'1','2','3','4'"; //<==갤러리 게시판이 1, 2, 3, 4 

$qq=sql_query("select * from {$g5['board_file_table']} where bo_table IN($tableStr) order by bf_datetime desc, wr_id desc ");

while($row= sql_fetch_array($qq)){ $img = G5_DATA_URL.'/'.$row['bo_table'].'/'.$row['bf_file'];

<a href="링크 필요하면 넣기"><img src='<?php echo $img;?>' class='myimg'></a>

<?php }?>

 

썸네일 생성이라든지 클릭하면 큰 이미지보기라든지 몇가지 기능 추가가 필요하겠군요

 

 

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 764
© SIRSOFT
현재 페이지 제일 처음으로