각 페이지별 다른 이미지 불러오는 수스 좀 부탁드립니다. > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

각 페이지별 다른 이미지 불러오는 수스 좀 부탁드립니다. 정보

각 페이지별 다른 이미지 불러오는 수스 좀 부탁드립니다.

본문

<?
include_once("./_common.php");
include_once("$g4[path]/lib/latest.lib.php");
include_once("_head.php");
?>

<table width="100%" height="189" background="/imgs/sub/top_bg.png" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top" >
      <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
      <td><img src="/imgs/sub/sub_img1.png" width="1000" height="183" /></td>
      </tr>
    </table>
    </td>
  </tr>
</table>

---------------------------------------------------------------------------------------

위에는 이미지만 따로 넣어놓은 pnp소스고요
밑에는 각각의 페이지 마다 위에 php를 이용하여 각각의 이미지가 나올수 있도록요

[info1_1.php/info1_2.php/info1_3.php]sub_img1.png
[info2_1.php/info2_2.php/info2_3.php]sub_img2.png
[info3_1.php/info3_2.php/info3_3.php]sub_img3.png


각각의 서브 이미지가 달라진다고 생각하시면 되는데...
알려주세요
  • 복사

댓글 전체

함수를 이용하시면 됩니다.

$currentPage = $_SERVER['PHP_SELF'];

if($currentPage=='info1_1.php' or $currentPage=='info1_3.php' ){
$img = 'sub_img1.png ';
}else if($currentPage=='info2_2.php' or $currentPage=='info2_3.php'){
$img = 'sub_img2.png ';
}else{
$img = 'sub_img3.png ';
}

<img src='<?=$img?>' />

문법이나 콤마 등이 빠졌을수 있으니 참고해서 본인이 수정하시면 될거에요.
모니터군님 땡큐합니다.
그런데요~ 이미지가 경로가 안잡히네요


<?
include_once("./_common.php");
include_once("$g4[path]/lib/info.lib.php");
include_once("_head.php");

?>

<table width="100%" height="189" background="/imgs/sub/top_bg.png" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top" >
      <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
      <td><img src='<?=$img?>' /></td>
      </tr>
    </table>
    </td>
  </tr>
</table>


제가 이미지 나올 소스를 저기다가 붙쳤고요
include_once("$g4[path]/lib/info.lib.php");
여기 안에다가 주신 소스를 밑에와 같이 넣었습니다.


<?
if (!defined('_GNUBOARD_')) exit;

$currentPage = $_SERVER['PHP_SELF'];

if($currentPage=='info1_1.php' or $currentPage=='info1_4.php' ){
$img = 'imgs/sub/sub_img1.png ';
}
else if($currentPage=='info2_1.php' or $currentPage=='info2_6.php'){
$img = 'imgs/sub/sub_img2.png ';
}
else if($currentPage=='info3_1.php' or $currentPage=='info3_4.php'){
$img = 'imgs/sub/sub_img3.png ';
}
else if($currentPage=='info4_1.php'){
$img = 'imgs/sub/sub_img4.png ';
}
else if($currentPage=='info5_1.php' or $currentPage=='info5_2.php'){
$img = 'imgs/sub/sub_img5.png ';
}

?>



그랬더니 이미지는 엑박으로 뜨고 http://munchun.woobi.co.kr/info/ 저렇게 밖에 경로가 안잡히더라고요

죄송하지만 어디가 잘못됬는제 부탁드립니다.
<?
if (!defined('_GNUBOARD_')) exit;

$currentPage = $_SERVER['PHP_SELF'];

if($currentPage=="/info/info1_1.php" or $currentPage=="/info/info1_2.php" or $currentPage=="/info/info1_3.php"  or $currentPage=="/info/info1_4.php"  ){
$img = "/imgs/sub/sub_img1.png ";
}
else if($currentPage=="/info/info2_1.php" or $currentPage=="/info/info2_2.php" or $currentPage=="/info/info2_3.php"  or $currentPage=="/info/info2_4.php"  or $currentPage=="/info/info2_5.php"  or $currentPage=="/info/info2_6.php"  ){
$img = "/imgs/sub/sub_img2.png ";
}
else if($currentPage=="/info/info3_1.php" or $currentPage=="/info/info3_2.php"  or $currentPage=="/info/info3_3.php"  or $currentPage=="/info/info3_4.php"){
$img = "/imgs/sub/sub_img3.png ";
}
else if($currentPage=="/info/info4_1.php"){
$img = "/imgs/sub/sub_img4.png ";
}
else if($currentPage=="/info/info5_1.php" or $currentPage=="/info/info5_2.php"){
$img = "/imgs/sub/sub_img5.png ";
}


?>



붙치기ㅋㅋ
<img src='<?=$img?>' />



위와 같이 적용하니 되네요^^
© SIRSOFT
현재 페이지 제일 처음으로