Copy
<?php ?> $thumbsrc = ""; if ($list[$i]["bo_image_head"]) { $thumbsrc = $file_able_path ."/". $list[$i]["bo_image_head"]; } $hlink = ""; if ($list[$i]["bo_link"]) { if ($list[$i]["bo_target"] == "1") { $htarget = "_self"; } else { $htarget = "_blank"; } $hlink = "<a href='".$list[$i]["bo_link"]."' target='$htarget' />"; } ?> <li><p align="center"><?php echo $hlink;?><img src="<?php echo $thumbsrc;?>" title="<?php echo $list[$i]["bo_subject"];?>" border=0 width="<?php echo $thumb_width;?>" height="<?php echo $thumb_height;?>" /></a></p></li> <?php } ?>
짜집기만 하는 초보라 잘 모르겠네요. ㅠㅠ 위의 코드가 등록한 이미지 만큼 나오더라구요.
근데 이걸 랜덤으로 1개만 나오게 하고싶습니다. (5개 등록 했다고 하면 램던으로 1개만 나오게 하고싶습니다.
|
답변 1개 / 댓글 2개
채택된 답변
+20 포인트
11년 전
코드가 모두 다 적어주신게 아니라서..
일단은 등록한 이미지 갯수만큼 출력이 된다는건 for 등으로 반복해서 돌렸다는 것 같구요.
반복구문을 제거하시면 될것같고.. 랜덤으로 1개만 가져오시려면..
데이터를 가져오는 쿼리를 select * from tablename order by rand() limit 1; 와 같이 해보세요.
답변에 대한 댓글 2개
답변을 작성하려면 로그인이 필요합니다.