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

list type별 이미지 채택완료

blue4u 10년 전 조회 3,162

신상품,히트상품 이런 각 리스트별 이미지를 넣고 싶은데요.

 

 

$type = $_REQUEST['type'];

if ($type == 1)   { 

$echo= '';

}else if ($type == 2) {$echo= '';} 

?>

 

 

아주 엉터리인데 이걸 다듬어 주실수 있을까요ㅠㅠ;;

 

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

답변 1개

채택된 답변
+20 포인트

조건이 많은건 switch case문을 쓰시는게 좋아요.

 

</p><p>switch($type){</p><p>    case 1:</p><p><span style="font-size: 13.3333330154419px; line-height: 1.5;">   </span><span style="font-size: 13.3333330154419px; line-height: 1.5;"> </span><span style="font-size: 13.3333330154419px; line-height: 1.5;">   </span><span style="font-size: 13.3333330154419px; line-height: 1.5;"> </span><span style="font-size: 13.3333330154419px; line-height: 1.5;">​echo '<img src='/images1.gif' /></span><span style="font-size: 10pt; line-height: 1.5;">​</span></p><p><span style="font-size: 13.3333330154419px; line-height: 1.5;">   </span><span style="font-size: 13.3333330154419px; line-height: 1.5;"> </span><span style="font-size: 13.3333330154419px; line-height: 1.5;">   </span><span style="font-size: 13.3333330154419px; line-height: 1.5;"> </span><span style="font-size: 13.3333330154419px; line-height: 1.5;">​break;</span><span style="font-size: 10pt; line-height: 1.5;">​</span></p><p style="font-size: 13.3333330154419px;">    case 2:</p><p style="font-size: 13.3333330154419px;"><span style="font-size: 13.3333330154419px; line-height: 1.5;">   </span><span style="font-size: 13.3333330154419px; line-height: 1.5;"> </span><span style="font-size: 13.3333330154419px; line-height: 1.5;">   </span><span style="font-size: 13.3333330154419px; line-height: 1.5;"> </span><span style="font-size: 13.3333330154419px; line-height: 1.5;">​echo '<img src='/images2.gif' /></span><span style="font-size: 10pt; line-height: 1.5;">​</span></p><p><span style="font-size: 13.3333330154419px; line-height: 1.5;">   </span><span style="font-size: 13.3333330154419px; line-height: 1.5;"> </span><span style="font-size: 13.3333330154419px; line-height: 1.5;">   </span><span style="font-size: 13.3333330154419px; line-height: 1.5;"> </span><span style="font-size: 13.3333330154419px; line-height: 1.5;">​break;</span><span style="font-size: 10pt; line-height: 1.5;">​</span></p><p style="font-size: 13.3333330154419px;">    case 3:</p><p style="font-size: 13.3333330154419px;"><span style="font-size: 13.3333330154419px; line-height: 1.5;">   </span><span style="font-size: 13.3333330154419px; line-height: 1.5;"> </span><span style="font-size: 13.3333330154419px; line-height: 1.5;">   </span><span style="font-size: 13.3333330154419px; line-height: 1.5;"> </span><span style="font-size: 13.3333330154419px; line-height: 1.5;">​echo '<img src='/images3.gif' /></span><span style="font-size: 10pt; line-height: 1.5;">​</span></p><p><span style="font-size: 13.3333330154419px; line-height: 1.5;">   </span><span style="font-size: 13.3333330154419px; line-height: 1.5;"> </span><span style="font-size: 13.3333330154419px; line-height: 1.5;">   </span><span style="font-size: 13.3333330154419px; line-height: 1.5;"> </span><span style="font-size: 13.3333330154419px; line-height: 1.5;">​break;</span><span style="font-size: 10pt; line-height: 1.5;">​</span><span style="font-size: 10pt; line-height: 1.5;"></span><span style="font-size: 10pt; line-height: 1.5;"></span></p><p><span style="font-size: 10pt; line-height: 1.5;">...</span></p><p>}</p><p>

 

case는 $type에 들어가있는거에요. 히트상품이 1이 아니라 hit라고 되어있으면 case "hit": 라고 해야해요.

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

답변에 대한 댓글 1개

b
blue4u
10년 전
아 네 감사합니다.
대충 다른거 어떻게 썼는지 따라 써봤는데
$type = $_REQUEST['type'];
if ($type == 1) echo '<img src=/images/tit_hit.jpg>';
else if ($type == 2) echo '<img src=/images/tit_best.jpg>';
else if ($type == 3) echo '<img src=/images/tit_new.jpg>';
else if ($type == 4) echo '<img src=/images/tit_hot.jpg>';
else if ($type == 5) echo '<img src=/images/tit_sale.jpg>';

이렇게 하니 되긴하더라구요.

알려주신 소스로 바꿔넣어야겠네요.

감사합니다.^^

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

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

로그인