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>
<? } ?>
<?
}
아이디 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>
<? } ?>
<?
}
답변 2
이렇게 질문 하시면 "나 모르겠으니까 코드 보고 알아서 풀어줘" 랑 뭐가 다를까요??
모르경우에는 우선 검색을 해보시고
못 찾았을 경우 다른사람들이 금방보고 어떤것이 문제인지를 쉽게 알수있게 요점만 추려서 질문을 하셔야
답변을 받을 수 있지 않을까요?
모르경우에는 우선 검색을 해보시고
못 찾았을 경우 다른사람들이 금방보고 어떤것이 문제인지를 쉽게 알수있게 요점만 추려서 질문을 하셔야
답변을 받을 수 있지 않을까요?
같은 질문을 몇번 한 것같은데 시누이님 말씀처럼 그누보드 기본 소스가 아니기 때문에
코드만 보고서는 답변하기가 어렵겠습니다
질문 내용과 사이트 그래프로 추측하자면 2명에 해당하는 것은 100%로 하고 1명은 50%
10명이 최대라면 5명은 50%, 1명은 10%...
이런 내용같은데 맞는가요?
(질문 자체를 이런식으로 해야 남이 금방 알아먹죠...이해하기 아려운 질문에 답변하려는 사람은 없을테니까요)
1. 최대치 구하기 : for문 위쪽에 추가
$maxk=sql_fetch("select vt_hit from $mw[vote_item_table] where vt_id = '$vote[vt_id]'");
2. 퍼센트 계산( $vote[vt_total] --> $maxk[vt_hit] 로 변경)
$vt_rate=$row[vt_rate]=0;
if ( !$row[vt_hit]) $row[vt_hit]=0;
$vt_rate = @round($row[vt_hit] / $maxk[vt_hit], 2) * 100;
if ($vt_rate) $row[vt_rate] = $vt_rate."% (".number_format($row[vt_hit]).") </span>";
$row[vt_width] = @intval($width * ($vt_rate / 100));
if ($vt_rate) $row[vt_rate] = $vt_rate."% (".number_format($row[vt_hit]).") </span>";
$row[vt_width] = @intval($width * ($vt_rate / 100));
정확한 내용을 모르니 맞는지 모르겠네요
하여튼 최대값 vt_hit 기준으로 상대적 퍼센트를 내는 것입니다
답변을 작성하시기 전에 로그인 해주세요.