퍼센트 비율 잡기는 어떻게 해야 할까요? 채택완료
예를들어
<div class="progress">
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">25%
</div>
</div>
이건 100일때 25프로니깐 25퍼센트가 표시가 될건데요~
만약에 1부터 125라고 한다면
125가 되야 100%로가 되는데요~
100이면 약 80% 정도 되겠죠?
이걸 어떻게 수정해야 할까요?
답변 9개
</p>
<pre>
$num = 25;
$percent = $num / 125 * 100;
echo $percent;</pre>
<p>
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
추가 피해자 방지 https://sir.kr/conflictconsultation/245" rel="nofollow noreferrer noopener" target="_blank">https://sir.kr/conflictconsultation/245
댓글을 작성하려면 로그인이 필요합니다.
그냥 표시부에 써주시면 될 듯...
<?php
$cur = 100; // 현재값
$max = 125; // 최대값
$per = $cur/$max*100; // 퍼센트
?>
<div class="progress">
<div class="progress-bar" role="progressbar" style="width: <?php echo $per;?>%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"><?php echo $cur;?>/<?php echo $max;?> (∴ <?php echo $per;?>%)
</div>
</div>
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
댓글을 작성하려면 로그인이 필요합니다.
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인