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

if문 문의 채택완료

천재중천재 10년 전 조회 3,162

</strong></p><p><strong>if($row['it_soldout'] == '1' && $row['it_tel_inq'] !== '1') {
$discount_percent = "품절";
} else if($row['it_tel_inq'] == '1') {
$discount_percent = "문의";
} else {
$cost_value = $row['it_cust_price']; //원가
$discount_value = get_price($row); //할인가 = 판매가격
$discount_percent = (($cost_value - $discount_value) / $cost_value) * 100;
$discount_percent = round($discount_percent, 0)."%";
}
//echo "<div class=\"sct_cost\">\n";
echo "<span class=\"item_percent\">".$discount_percent."</span>";
</strong></p><p><strong>


위와 같은 소스에서


$cost_value가 0일때 0으로는 나눗셈을 못해 에러가 납니다.

0일때는

</strong><strong></strong></p><p><strong>$discount_percent = (($cost_value - $discount_value) / $cost_value) * 100;</strong></p><p><strong></strong><strong>

이부분을 건너띄고 싶습니다.

if문을 써야되는데 잘안먹어요 ㅜㅜ

고수님들 도와주세요~

 

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

답변 2개

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

if($cost_value !=0)

    $discount_percent = (($cost_value $discount_value) / $cost_value) * 100;

else

    $discount_percent = 0;

 

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

답변에 대한 댓글 1개

천재중천재
10년 전
컨트롤 c+v로 할 수 있게 해주시면 감사..
계속 에러나서 ㅡㅡ;

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

겨바리
10년 전

</p><p><span style="font-size: 14.6666669845581px; line-height: 1.5;">$discount_percent = </span><span style="font-size: 14.6666669845581px; line-height: 1.5;">$cost_value</span><span style="font-size: 14.6666669845581px; line-height: 1.5;">​ > 0 ? (($cost_value - $discount_value) / $cost_value) * 100 : 0;</span><span style="font-size: 11pt; line-height: 1.5;">​</span></p><p>

 

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

답변에 대한 댓글 1개

천재중천재
10년 전
이건도 에러 나는데요..ㅡㅜ

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

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

로그인