설문그래프 100%에서 줄어들기 정보
설문그래프 100%에서 줄어들기본문
오류가 나는곳의 주소를 알려주시면 더 빠르고 정확하게 답변 받을 수 있습니다.
오류 주소 :
http://www.monsterbox.co.kr/bbs/board.php?bo_table=mb26&wr_id=2
아이디 test 비번 test
주소로 들어가서 결과보기하시면 설문 그래프가 나오는데요......
총 100%에서 항목별로 그래프가 표시되는데
이렇게 말고 제일 높은 수치를 무조건 100%로 표기되고 나머지 항목은 수치별로 나타낼 방법이 없을까요?
아래는 해당 코드입니다.
$width = $_GET['width'];
$width = 900;
if ($mw_basic[cf_vote]) {
$vote = sql_fetch("select * from $mw[vote_table] where bo_table = '$bo_table' and wr_id = '$wr_id'");
$vote_list = array();
$sql = "select * from $mw[vote_item_table] where vt_id = '$vote[vt_id]'";
$qry = sql_query($sql);
for ($i=0; $row=sql_fetch_array($qry); $i++) {
$row[vt_rate] = @round($row[vt_hit] / $vote[vt_total], 2) * 100;
if ($row[vt_rate])
$row[vt_rate] = $row[vt_rate]."% (".number_format($row[vt_hit]).") </span>";
else
$row[vt_rate] = "0";
$row[vt_width] = @intval($width * ($row[vt_rate] / 100));
$row[vt_item] = cut_str(get_text(strip_tags($row[vt_item])), 50);
$vote_list[$i] = $row;
}
if ($vote[vt_multi]) {
$qry = sql_query("select count(*) as cnt from $mw[vote_log_table] where vt_id = '$vote[vt_id]' group by mb_id");
$vt_total = mysql_num_rows($qry);
}
else {
$vt_total = $vote[vt_total];
}
if ($write[mb_id] == $member[mb_id]) { // 자신의 글은 그냥 출력
$is_vote = true;
} else {
$is_vote = false;
if ($vote[vt_sdate] != "0000-00-00 00:00:00" && $g4[time_ymdhis] < $vote[vt_sdate]) {
$is_vote = true;
} else if ($vote[vt_edate] != "0000-00-00 00:00:00" && $g4[time_ymdhis] > $vote[vt_edate]) {
$is_vote = true;
} else {
if ($is_member) $row = sql_fetch("select * from $mw[vote_log_table] where vt_id = '$vote[vt_id]' and mb_id = '$member[mb_id]'");
else $row = sql_fetch("select * from $mw[vote_log_table] where vt_id = '$vote[vt_id]' and vt_ip = '$_SERVER[REMOTE_ADDR]'");
if ($row)
$is_vote = true;
}
}
}
$gr = array();
for ($i=1; $i<=10; $i++) $gr[] = $i;
shuffle($gr);
$img_path = "$g4[url]/skin/board/$board[bo_skin]/img/";
if ($mw_basic[cf_vote] && $vote && sizeof($vote_list)) {
?>
<div class="fs cc h50"></div>
<div class="cc w100p h30 downline">
<div class="aleft bleft h30 lh34"><img src="<?=$g4[path]?>/img/vote.png" align="absmiddle" style="margin:-4px 6px 0 0;"><span class="fontw b">설문조사</span><span class="date">|</span><?=number_format($vt_total)?>명 참여</div>
<div class="aright bright text11 fonts h30 lh34"><? if ($vote[vt_sdate] != "0000-00-00 00:00:00") echo substr($vote['vt_sdate'],2,2).".".substr($vote['vt_sdate'],5,2).".".substr($vote['vt_sdate'],8,2)." (".get_yoil($vote[vt_sdate]).") ".substr($vote[vt_sdate],11,2)."시 <span class='fontss text11'>-</span> ";
if ($vote[vt_edate] != "0000-00-00 00:00:00") echo substr($vote['vt_edate'],2,2).".".substr($vote['vt_edate'],5,2).".".substr($vote['vt_edate'],8,2)." (".get_yoil($vote[vt_edate]).") ".substr($vote[vt_edate],11,2)."시 까지";
if ($vote[vt_point]) echo "<span class='date'>|</span>".number_format($vote[vt_point])."P 지급<span class='date'>|</span>";
if ($vote[vt_multi]) echo $vote[vt_multi]."개까지 복수선택 가능"; ?><? if ($is_admin) { ?><span class='date'>|</span><a href="#;" onclick="win_open('<?=$board_skin_path?>/proc/vote.list.php?bo_table=<?=$bo_table?>&wr_id=<?=$wr_id?>', 'vote_list', 'width=700,height=700,scrollbars=1');"><span class="fontb b text11">참여목록</span></a><? } ?></div>
</div>
<? if (!$is_vote && !$result_view) { //--------------------------------설문참여안함?>
<div class="cc">
<? for ($i=0; $i<sizeof($vote_list); $i++) { ?>
<div class="cc h32 lh34 downline bleft">
<? if (!$vote[vt_multi]) { ?>
<input type="radio" id="vt_num_<?=$i?>" name="vt_num" value="<?=$i?>">
<? } else { ?>
<input type="checkbox" id="vt_num_<?=$i?>" name="vt_num" value="<?=$i?>">
<? } ?>
<label for="vt_num_<?=$i?>"><?=$vote_list[$i][vt_item]?></label>
</div>
<? } //for?>
<div class="cc h40 bleft" style="margin-top:20px;"><input type="button" value="설문참여" class="btnr w100 cu" onclick="mw_vote_join()"><input type="button" value="결과보기" class="btns cu w100" onclick="mw_vote_result()"></div>
</div>
<? } else { //--------------------------------------설문결과?>
<div class="cc">
<? for ($i=0; $i<sizeof($vote_list); $i++) {
$line = $i%2; // 홀수,짝수
if ($line == "1") { $bgline = "#3e0002"; }else{ $bgline = "#4e0003";} ?>
<div class="cc h32 lh32 downline bleft" >
<div style="position:absoulte;z-index:10;">
<div class="aleft bleft h30 lh34"><span class="date"></span><?=$vote_list[$i][vt_item]?></div>
<div class="aright bright h30 lh34"><nobr><?=$vote_list[$i][vt_rate]?></nobr><span style="padding-right:6px;"></span></div>
</div>
<div class="h32" style="background-color:<?=$bgline?>;width:<?=$vote_list[$i][vt_width]?>px;"></div>
</div>
<? } //for?>
<? if ($result_view) { ?>
<div class="cc h40 bleft" style="margin-top:20px;"><input type="button" value="설문참여" class="btns w100 cu" onclick="mw_vote_load()"></div>
<? } ?>
</div>
<? } ?>
<?
}
오류 주소 :
http://www.monsterbox.co.kr/bbs/board.php?bo_table=mb26&wr_id=2
아이디 test 비번 test
주소로 들어가서 결과보기하시면 설문 그래프가 나오는데요......
총 100%에서 항목별로 그래프가 표시되는데
이렇게 말고 제일 높은 수치를 무조건 100%로 표기되고 나머지 항목은 수치별로 나타낼 방법이 없을까요?
아래는 해당 코드입니다.
$width = $_GET['width'];
$width = 900;
if ($mw_basic[cf_vote]) {
$vote = sql_fetch("select * from $mw[vote_table] where bo_table = '$bo_table' and wr_id = '$wr_id'");
$vote_list = array();
$sql = "select * from $mw[vote_item_table] where vt_id = '$vote[vt_id]'";
$qry = sql_query($sql);
for ($i=0; $row=sql_fetch_array($qry); $i++) {
$row[vt_rate] = @round($row[vt_hit] / $vote[vt_total], 2) * 100;
if ($row[vt_rate])
$row[vt_rate] = $row[vt_rate]."% (".number_format($row[vt_hit]).") </span>";
else
$row[vt_rate] = "0";
$row[vt_width] = @intval($width * ($row[vt_rate] / 100));
$row[vt_item] = cut_str(get_text(strip_tags($row[vt_item])), 50);
$vote_list[$i] = $row;
}
if ($vote[vt_multi]) {
$qry = sql_query("select count(*) as cnt from $mw[vote_log_table] where vt_id = '$vote[vt_id]' group by mb_id");
$vt_total = mysql_num_rows($qry);
}
else {
$vt_total = $vote[vt_total];
}
if ($write[mb_id] == $member[mb_id]) { // 자신의 글은 그냥 출력
$is_vote = true;
} else {
$is_vote = false;
if ($vote[vt_sdate] != "0000-00-00 00:00:00" && $g4[time_ymdhis] < $vote[vt_sdate]) {
$is_vote = true;
} else if ($vote[vt_edate] != "0000-00-00 00:00:00" && $g4[time_ymdhis] > $vote[vt_edate]) {
$is_vote = true;
} else {
if ($is_member) $row = sql_fetch("select * from $mw[vote_log_table] where vt_id = '$vote[vt_id]' and mb_id = '$member[mb_id]'");
else $row = sql_fetch("select * from $mw[vote_log_table] where vt_id = '$vote[vt_id]' and vt_ip = '$_SERVER[REMOTE_ADDR]'");
if ($row)
$is_vote = true;
}
}
}
$gr = array();
for ($i=1; $i<=10; $i++) $gr[] = $i;
shuffle($gr);
$img_path = "$g4[url]/skin/board/$board[bo_skin]/img/";
if ($mw_basic[cf_vote] && $vote && sizeof($vote_list)) {
?>
<div class="fs cc h50"></div>
<div class="cc w100p h30 downline">
<div class="aleft bleft h30 lh34"><img src="<?=$g4[path]?>/img/vote.png" align="absmiddle" style="margin:-4px 6px 0 0;"><span class="fontw b">설문조사</span><span class="date">|</span><?=number_format($vt_total)?>명 참여</div>
<div class="aright bright text11 fonts h30 lh34"><? if ($vote[vt_sdate] != "0000-00-00 00:00:00") echo substr($vote['vt_sdate'],2,2).".".substr($vote['vt_sdate'],5,2).".".substr($vote['vt_sdate'],8,2)." (".get_yoil($vote[vt_sdate]).") ".substr($vote[vt_sdate],11,2)."시 <span class='fontss text11'>-</span> ";
if ($vote[vt_edate] != "0000-00-00 00:00:00") echo substr($vote['vt_edate'],2,2).".".substr($vote['vt_edate'],5,2).".".substr($vote['vt_edate'],8,2)." (".get_yoil($vote[vt_edate]).") ".substr($vote[vt_edate],11,2)."시 까지";
if ($vote[vt_point]) echo "<span class='date'>|</span>".number_format($vote[vt_point])."P 지급<span class='date'>|</span>";
if ($vote[vt_multi]) echo $vote[vt_multi]."개까지 복수선택 가능"; ?><? if ($is_admin) { ?><span class='date'>|</span><a href="#;" onclick="win_open('<?=$board_skin_path?>/proc/vote.list.php?bo_table=<?=$bo_table?>&wr_id=<?=$wr_id?>', 'vote_list', 'width=700,height=700,scrollbars=1');"><span class="fontb b text11">참여목록</span></a><? } ?></div>
</div>
<? if (!$is_vote && !$result_view) { //--------------------------------설문참여안함?>
<div class="cc">
<? for ($i=0; $i<sizeof($vote_list); $i++) { ?>
<div class="cc h32 lh34 downline bleft">
<? if (!$vote[vt_multi]) { ?>
<input type="radio" id="vt_num_<?=$i?>" name="vt_num" value="<?=$i?>">
<? } else { ?>
<input type="checkbox" id="vt_num_<?=$i?>" name="vt_num" value="<?=$i?>">
<? } ?>
<label for="vt_num_<?=$i?>"><?=$vote_list[$i][vt_item]?></label>
</div>
<? } //for?>
<div class="cc h40 bleft" style="margin-top:20px;"><input type="button" value="설문참여" class="btnr w100 cu" onclick="mw_vote_join()"><input type="button" value="결과보기" class="btns cu w100" onclick="mw_vote_result()"></div>
</div>
<? } else { //--------------------------------------설문결과?>
<div class="cc">
<? for ($i=0; $i<sizeof($vote_list); $i++) {
$line = $i%2; // 홀수,짝수
if ($line == "1") { $bgline = "#3e0002"; }else{ $bgline = "#4e0003";} ?>
<div class="cc h32 lh32 downline bleft" >
<div style="position:absoulte;z-index:10;">
<div class="aleft bleft h30 lh34"><span class="date"></span><?=$vote_list[$i][vt_item]?></div>
<div class="aright bright h30 lh34"><nobr><?=$vote_list[$i][vt_rate]?></nobr><span style="padding-right:6px;"></span></div>
</div>
<div class="h32" style="background-color:<?=$bgline?>;width:<?=$vote_list[$i][vt_width]?>px;"></div>
</div>
<? } //for?>
<? if ($result_view) { ?>
<div class="cc h40 bleft" style="margin-top:20px;"><input type="button" value="설문참여" class="btns w100 cu" onclick="mw_vote_load()"></div>
<? } ?>
</div>
<? } ?>
<?
}
댓글 전체
위 코드는 전체 개수에 대해 백분율로 뽑는듯 한데
항목별 카운트를 group by로 뽑으시고
뽑아진 항목이
a 2,
b 2,
c 3,
d 4,
e, 3
라 하시면
(각 항목별 / 가장높은 항목) * 100
d가 가장높으니
(a/d) * 100
(b/d) * 100
(c/d) * 100
(d/d) * 100
(e/d) * 100
으로 계산을 하시면 바로 나올듯 한데요..
항목별 카운트를 group by로 뽑으시고
뽑아진 항목이
a 2,
b 2,
c 3,
d 4,
e, 3
라 하시면
(각 항목별 / 가장높은 항목) * 100
d가 가장높으니
(a/d) * 100
(b/d) * 100
(c/d) * 100
(d/d) * 100
(e/d) * 100
으로 계산을 하시면 바로 나올듯 한데요..
죄송하지만 이해가 안갑니다 ㅡㅜ
간단한 산수로 구해집니다.
문항수 : 구할 퍼센트 = 제일높은수치 : 100%
구할 퍼센트 = (문항수 / 제일높은 수치) *100%
문항수 : 구할 퍼센트 = 제일높은수치 : 100%
구할 퍼센트 = (문항수 / 제일높은 수치) *100%