테스트 사이트 - 개발 중인 베타 버전입니다

메인에 최신글 이미지를 불러오고싶은데요 채택완료

구름해 8년 전 조회 3,737

빨간색 네모부분이 계속 변경되는 부분인데

코딩을 어떻게 해야지 그 게시물의 사진이 불러와질까요?ㅠㅠ 도와주세요

참고로 이미지들은 파일로 올린게 아니고 게시판 내용 안의 사진에서 올린겁니다



 

댓글을 작성하려면 로그인이 필요합니다.

답변 2개

채택된 답변
+20 포인트
8년 전

간단하게 ! 



<?php 


$sql = "select *from g5_board_file where 1 order by wr_id desc limit 1";


$row = sql_fetch($sql);


//echo $row['bf_file'];


?>

<p style="background-image:url(/data/cheditor4/<?php $row['bf_file'];?>);"></p>

로그인 후 평가할 수 있습니다

답변에 대한 댓글 2개

구름해
8년 전
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<?php

$sql = "select *from g4_board_file where 1 order by wr_id desc limit 1";

$row = sql_fetch($sql);

echo $row['bf_file'];

?>
<h2>ㅇㅇㅇ</h2><a href="<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>" class="latest_more_btn">더보기+</a>
<ul class="review_slide02">
<? for ($i=0; $i<count($list); $i++) { ?>
<li>
<a href="<?=$list[$i]['href']?>" class="view1-1">

<p style="background-image:url(/data/cheditor4/<?php $row['bf_file'];?>);"></p>
<article>
<?=$list[$i]['subject']?>
</article>
</a>
</li>
<? } ?>
</ul>
<script>
$(document).ready(function(){
$('.review_slide02').bxSlider({
mode:'horizontal',
pause: 4000, // 멈추는시간
auto: true,
autoHover: true,
minSlides: 1,
maxSlides: 1,
slideMargin: 0,
moveSlides: 1,
controls:false,
pager:true
});
});
</script>


이런식으로했는데 메인에
select *from g4_board_file where 1 order by wr_id desc limit 1
1146 : Table 'gmsaeum.g4_board_file' doesn't exist
error file : /index.new.php
이렇게 오류가 떠요ㅠㅠ
하찌
8년 전
그누보드4와 5의 테이블, 필드명이 서로 다를 수 있습니다.

그누보드 5로 예를들면 아래와 같이 이런식으로 echo 찍어보고

반복문 안의 이미지 경로에 파일명 echo로 출력시켜주면 될겁니다


[code]
<?php
$sql = "select *from g5_board_file where 1 order by wr_id desc";

$res = sql_query($sql);

for($i=0; $row=sql_fetch_array($res); $i++){
echo $row['bf_file']."<br>";
}
?>
[/code]

댓글을 작성하려면 로그인이 필요합니다.

플라이
8년 전

$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];

이미지 경로를 잡아서 파일 주소에

<?=$file?>

이렇게 처리해 주시면 됩니다.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

구름해
8년 전
<p style="background-image:url(<?$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];?>);"></p>
그럼 이렇게 사용하면 되는건가요???ㅠㅠㅠ

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인