Poll script
Ik heb 2 vragen over een Poll script, nu heb ik dus een redelijk groot poll script, met 3 querys. Ik weet dat dit makelijker kan, maar kom er niet op.
Ook weet ik niet hoe ik de percentage moet uitrekenen om dit weer te geven..
Ik heb nu dit:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
$pollQuery = $core->db->query("SELECT vraag, id FROM cms_poll WHERE active = '1' LIMIT 1");
$pollFetch = $core->db->fetch($pollQuery);
$telQuery = $core->db->query("SELECT COUNT(id) as tellen FROM cms_poll_votes WHERE poll_id = '".$pollFetch['id']."' AND user_id = '".$user['id']."' LIMIT 1");
$telFetch = $core->db->fetch($telQuery);
?>
<div class="pollquestion_12"><strong><?php echo $pollFetch['vraag']; ?></strong></div>
<div class="pollwrapper_12">
<?php
$answareQuery = $core->db->query("SELECT answare FROM cms_poll_answare WHERE poll_id = '".$pollFetch['id']."'");
while($answareFetch = $core->db->fetch($answareQuery))
{
if($telFetch['tellen'] > 0)
{
echo'<div class="answer_12">
<div class="answer12_text">'.$answareFetch['answare'].' ([procent]%)</div>
<div class="poll_background">
<div class="poll_vote" style="width:[procent]px;"></div>
</div>
</div>';
}else{
echo'<div class="answer_12">
<input type="radio" onclick="voteBam();" name="vote" value="votes4">
'.$answareFetch['answare'].'
</div> ';
}
}
?>
$pollQuery = $core->db->query("SELECT vraag, id FROM cms_poll WHERE active = '1' LIMIT 1");
$pollFetch = $core->db->fetch($pollQuery);
$telQuery = $core->db->query("SELECT COUNT(id) as tellen FROM cms_poll_votes WHERE poll_id = '".$pollFetch['id']."' AND user_id = '".$user['id']."' LIMIT 1");
$telFetch = $core->db->fetch($telQuery);
?>
<div class="pollquestion_12"><strong><?php echo $pollFetch['vraag']; ?></strong></div>
<div class="pollwrapper_12">
<?php
$answareQuery = $core->db->query("SELECT answare FROM cms_poll_answare WHERE poll_id = '".$pollFetch['id']."'");
while($answareFetch = $core->db->fetch($answareQuery))
{
if($telFetch['tellen'] > 0)
{
echo'<div class="answer_12">
<div class="answer12_text">'.$answareFetch['answare'].' ([procent]%)</div>
<div class="poll_background">
<div class="poll_vote" style="width:[procent]px;"></div>
</div>
</div>';
}else{
echo'<div class="answer_12">
<input type="radio" onclick="voteBam();" name="vote" value="votes4">
'.$answareFetch['answare'].'
</div> ';
}
}
?>
Ik hoop dat iemand mij hiermee kan helpen.
(Het javascript gedeelte is nog niet af, maar dit lukt me.)
Bedankt,
Wouter
Gewijzigd op 10/06/2012 01:25:18 door Wouter Lolz
Er zijn nog geen reacties op dit bericht.