사진 올릴경우 첫번째사진이..
본문
bx-slider이용해서
분류별
슬라이더로 이미지 되도록
했는데
이미지들이 예전에 올린것부터
순서대로 나와요..
최근에 올린글이 가장ㅁ 먼저 나오게
수정어케하나요
<?php
include_once('./_common.php');
include_once('./_head.php');
$left_menu = 1;
$category = '상업공간';
// 해당 분류 이미지만 불러오기
$sql = "
select
a.*
, b.bf_file
from
g5_write_gallery as a
left outer join g5_board_file as b on a.wr_id = b.wr_id
where
a.ca_name = '{$category}'
and b.bo_table = 'gallery'
";
$result = sql_query($sql);
$path = "/data/file/gallery/"; // 기본 이미지 경로
$img_arr = array();
while ($row = sql_fetch_array($result)) {
$img = explode('.', $row['bf_file']);
// thumbnail check
$thumb = $path."thumb-".$img[0]."_174x124.".$img[1];
$li = array(
'caption' => $row['wr_subject']
, 'src' => $path.$row['bf_file']
);
if (is_file($_SERVER['DOCUMENT_ROOT'].$thumb)) {
$li['thumb'] = $thumb;
} else {
$li['thumb'] = $path.$row['bf_file'];
}
$img_arr[] = $li;
}
?>
<div class="Contents">
<?php include_once "left_menu.php"; ?>
<div class="Sub">
<link rel="stylesheet" href="../css/jquery.bxslider.css" type="text/css" media="screen" />
<script>
$(document).ready(function(){
$('.bxslider').bxSlider({
pagerCustom: '#bx-pager',
captions: true,
controls: false
});
$('.bxslider2').bxSlider({
slideWidth: 178,
minSlides: 2,
maxSlides: 3,
slideMargin: 0
});
});
</script>
<style>
.bx-wrapper .bx-prev { left:-84px !important; }
.bx-wrapper .bx-next { right:-84px !important; }
</style>
<div>
<ul class="bxslider">
<?php
foreach ($img_arr as $ia) {
echo "<li><img src='{$ia["src"]}' alt='' title='{$ia["caption"]}' style='804px; height:384px;' /></li>";
}
?>
</ul>
</div>
<div style="margin-top:20px; margin-bottom:20px; "><img src="../images/sub_slider_title.gif" alt="" /></div>
<div class="bxslider2" id="bx-pager">
<?php
for ($i = 0; $i < count($img_arr); $i++) {
?>
<a data-slide-index="<?=$i?>" href="#<?=$i?>"><img src="<?=$img_arr[$i]['thumb']?>" style="width:174px; height:124px;" /></a>
<?php
}
?>
</div>
<script src="../js/jquery.bxslider.js"></script>
</div>
</div>
</div> <!-- Contents End -->
<?php
include_once('./_tail.php');
?>
답변 1
$sql = " select a.* , b.bf_file from g5_write_gallery as a left outer join g5_board_file as b on a.wr_id = b.wr_id where a.ca_name = '{$category}' and b.bo_table = 'gallery' ORDER BY a.wr_id DESC ";
부분에 하면 될거같은데요?