갤러리에 이미지 파일 두개 이상 등록했을때 첫번째 파일을 메인으로 연동하는법
본문
답변 3
<div class="index_botoom_img_content">
<?php
$sql = "SELECT * FROM `g5_write_clean_gallery` ORDER BY `wr_id` DESC LIMIT 10";
$result = mysqli_query($connect_db, $sql);
$gallery = array();
$galleryfile = array();
for($i=0; $row = mysqli_fetch_assoc($result); $i++){
$gallery[$i] = $row;
$sql2 = "SELECT * FROM g5_board_file WHERE bf_no = 0 AND bo_table = 'clean_gallery' AND wr_id='{$row['wr_id']}'";
$result2 = mysqli_query($connect_db, $sql2);
$row2 = mysqli_fetch_assoc($result2);
$galleryfile[$i] = $row2;
}
?>
<div class="gallery_wrap">
<?php
for($i = 0; $i < count($gallery); $i++){ ?>
<a href="<?php echo '/bbs/board.php?bo_table=clean_gallery&wr_id='.$gallery[$i]['wr_id']; ?>" class="gallery_box">
<div class="gal_img">
<img src="<?php echo G5_DATA_URL ?>/file/clean_gallery/<?php echo $galleryfile[$i]['bf_file']; ?>" alt="">
</div>
<div class="gal_text">
<p><?php echo $gallery[$i]['wr_subject']; ?></p>
</div>
</a>
<?php }
?>
</div>
</div>
첫번째 게시물을 가져온 데이터에서 다시 파일을 가져오면 됩니다.
(소스로 올려주셔야 답변이 용이합니다.ㅜㅜ)
while($row = mysqli_fetch_assoc($result)) {
$gallery{} = $row;
$sql2 = "select * from g5_board_file where bo_table='clean_gallery' and wr_id='{$row['wr_id']}' and bf_no=0";
$result2 = ~~~
while($row2 = ~~~~) {
$galleryfile[] = $row2;
}
}
<div class="index_botoom_img_content">
<?php
$sql = "SELECT * FROM `g5_write_clean_gallery` ORDER BY `wr_id` DESC LIMIT 10";
$sql2 = "SELECT * FROM g5_board_file WHERE bf_no = 0 AND bo_table = 'clean_gallery'";
$result = mysqli_query($connect_db, $sql);
$result2 = mysqli_query($connect_db, $sql2);
$gallery = [];
$galleryfile = [];
while($row = mysqli_fetch_assoc($result)){
$gallery[] = $row;
}
while($row = mysqli_fetch_assoc($result2)){
$galleryfile[] = $row;
}
?>
<div class="gallery_wrap">
<?php
for($i = 0; $i < count($gallery); $i++){ ?>
<a href="<?php echo '/bbs/board.php?bo_table=clean_gallery&wr_id='.$gallery[$i]['wr_id']; ?>" class="gallery_box">
<div class="gal_img">
<img src="<?php echo G5_DATA_URL ?>/file/clean_gallery/<?php echo $galleryfile[$i]['bf_file']; ?>" alt="">
</div>
<div class="gal_text">
<p><?php echo $gallery[$i]['wr_subject']; ?></p>
</div>
</a>
<?php }
?>
</div>
</div>
답변을 작성하시기 전에 로그인 해주세요.