최신글에 이미지를 불러오고 싶습니다.
본문
게시판마다 공 이미지가 있는데
게시판은 총 10개고
구조는 아래처럼 짰는데
main_tab에 있는 이미지들을 최신글 동그라미친곳에 불러올 수 있을까요?
<ul class="main_tab">
<li class="on main_tab01"><img src="<?php echo G5_IMG_URL?>/all.png"/></li>
<li class="main_tab02"><img src="<?php echo G5_IMG_URL?>/soccer.png"/></li>
<li class="main_tab03"><img src="<?php echo G5_IMG_URL?>/baseball.png"/></li>
<li class="main_tab04"><img src="<?php echo G5_IMG_URL?>/basketball.png"/></li>
<li class="main_tab05"><img src="<?php echo G5_IMG_URL?>/hockey.png"/></li>
<li class="main_tab06"><img src="<?php echo G5_IMG_URL?>/football.png"/></li>
<li class="main_tab07"><img src="<?php echo G5_IMG_URL?>/volleyball.png"/></li>
<li class="main_tab08"><img src="<?php echo G5_IMG_URL?>/tennis.png"/></li>
<li class="main_tab09"><img src="<?php echo G5_IMG_URL?>/egame.png"/></li>
<li class="main_tab10"><img src="<?php echo G5_IMG_URL?>/lol.png"/></li>
<li class="main_tab11"><img src="<?php echo G5_IMG_URL?>/ufc.png"/></li>
<li class="main_tab12"><img src="<?php echo G5_IMG_URL?>/hd.png"/></li>
</ul>
<div class="main_sports_wrap">
<div class="sports_list sports_list_01">
<? echo latest_all('main_latest', '전체게시판', 50, 60 ,array('notice','free','gallery','analysis','event')); ?>
</div>
<div class="sports_list sports_list_02">
<?php
echo latest('main_latest', 'category02', 50, 60);
?>
</div>
<div class="sports_list sports_list_03">
<?php
echo latest('main_latest', 'category03', 50, 60);
?>
</div>
<div class="sports_list sports_list_04">
<?php
echo latest('main_latest', 'category04', 50, 60);
?>
</div>
<div class="sports_list sports_list_05">
<?php
echo latest('main_latest', 'category05', 50, 60);
?>
</div>
답변 3
<ul class="main_tab">
<li class="on main_tab01">
<?
$main_tab01_table='main_tab01';
$sql_main_tab01="select * from g5_write_".$main_tab01_table." where wr_is_comment = 0 order by wr_num";
$row_main_tab01 = sql_fetch($sql_main_tab01);
$thumb = get_list_thumbnail($main_tab01_table, $row_main_tab01['wr_id'], '200','150', false, true);
if($thumb['src']) {
$img_main_tab01 = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" >';
} else {
$img_main_tab01 = '<span class="no_image">no image</span>';
}
echo $img_main_tab01;
?>
</li>
<li class="main_tab02">
<?
$main_tab02_table='main_tab02';
$sql_main_tab02="select * from g5_write_".$main_tab02_table." where wr_is_comment = 0 order by wr_num";
$row_main_tab02 = sql_fetch($sql_main_tab02);
$thumb = get_list_thumbnail($main_tab02_table, $row_main_tab02['wr_id'], '200','150', false, true);
if($thumb['src']) {
$img_main_tab02 = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" >';
} else {
$img_main_tab02 = '<span class="no_image">no image</span>';
}
echo $img_main_tab02;
?>
</li>
<li class="main_tab03"><img src="<?php echo G5_IMG_URL?>/baseball.png"/></li>
<li class="main_tab04"><img src="<?php echo G5_IMG_URL?>/basketball.png"/></li>
<li class="main_tab05"><img src="<?php echo G5_IMG_URL?>/hockey.png"/></li>
<li class="main_tab06"><img src="<?php echo G5_IMG_URL?>/football.png"/></li>
<li class="main_tab07"><img src="<?php echo G5_IMG_URL?>/volleyball.png"/></li>
<li class="main_tab08"><img src="<?php echo G5_IMG_URL?>/tennis.png"/></li>
<li class="main_tab09"><img src="<?php echo G5_IMG_URL?>/egame.png"/></li>
<li class="main_tab10"><img src="<?php echo G5_IMG_URL?>/lol.png"/></li>
<li class="main_tab11"><img src="<?php echo G5_IMG_URL?>/ufc.png"/></li>
<li class="main_tab12"><img src="<?php echo G5_IMG_URL?>/hd.png"/></li>
</ul>
간단하게 보실려면 기본으로 최신글 pic_basic 보시면 썸네일 불러오는 부분이 있습니다. 참고하시면 될거 같습니다.
main_latest -> 제목 앞에 코드 추가
switch($table){ // 넘어온 게시판 아이디
case category02: $img = 'soccer'; break;
case category03: $img = 'baseball' ; break;
case category04: $img = 'basketball' ; break;
case category05: $img = 'hockey' ; break;
case category06: $img = 'football' ; break;
case category07: $img = 'volleyball' ; break;
case category08: $img = 'tennis'; break;
case category09: $img = 'egame' ; break;
case category10: $img = 'lol' ; break;
case category11: $img = 'ufc' ; break;
case category12: $img = 'hd' ; break;
default : $img = 'all' ; break;
?>
제목앞에 추가
<span><img src="<?php echo G5_IMG_URL?>/ <?php echo $img ?>.png"/></span>