Geachte forumleden,
Wij hebben een Poll script waar mensen op kunnen stemmen (logisch). Maar nu willen we dat de optie met de meeste stemmen boven aan komt.
Zodat we goed kunnen zien waarop het meest gestemd is.
Dit is de server side script.
Wij hebben een Poll script waar mensen op kunnen stemmen (logisch). Maar nu willen we dat de optie met de meeste stemmen boven aan komt.
Zodat we goed kunnen zien waarop het meest gestemd is.
Dit is de server side script.
PHP:
<?php
if ($totalpolls > 0) {
if (!isset ($_REQUEST['option']) && !isset ($_REQUEST['results']) && $votecookies != 'no' && $voteip != 'no' && $blocked != 'yes' && $started == 'yes' && $expired == 'no' && $polls['voting'] == 'yes') {
$poll = mysql_fetch_array (mysql_query ("SELECT pollid, title, voting, results, graph FROM polls WHERE pollid='$whatpoll'"));
$option = mysql_query ("SELECT optionid, options, order_id FROM options WHERE pollid='$whatpoll' ORDER BY order_id ASC");
?>
<form action="<?= $_SERVER['PHP_SELF']; ?>" method="post" name="frmPoll">
<table width="49%" border="0" cellspacing="0" cellpadding="2" class="border">
<tr class="text">
<td height="25" colspan="2" align="center"><b><?= $poll['title']; ?></b></td>
</tr>
<?php while ($optionrows = mysql_fetch_array ($option)) { ?>
<tr class="text">
<td width="10%" align="center" height="25"><input name="option" type="radio" value="<?= $optionrows['optionid']; ?>"<?php if ($optionrows['order_id'] == 1) { echo " CHECKED"; } ?>></td>
<td width="90%"><?= $optionrows['options']; ?></td>
</tr>
<?php } ?>
<tr>
<td colspan="2" align="center" height="25"><input name="stage" type="hidden" value="2"><input name="poll" type="hidden" value="<?= $poll['pollid']; ?>"><input name="btnVote" type="submit" value="Stemmen" class="text"><br /><br />
<?php if ($poll['results'] == 'yes' && $poll['graph'] == 'yes') { ?>
<?php } ?></td>
</tr>
</table>
</form>
<img src="images/layout/marker.gif" alt="" style="margin-right:3px; margin-left:1px; vertical-align:middle"><b><a href="?id=manofthematch&results=1">Bekijk de resultaten</a></b>
<?php
}
$poll = mysql_fetch_array (mysql_query ("SELECT pollid, title, voting, results, graph, resultsvotes FROM polls WHERE pollid='$whatpoll'"));
if (($blocked == 'yes' | $voteip == 'no' | $votecookies == 'no' | isset ($_REQUEST['results']) | $poll['voting'] == 'no' | isset ($_REQUEST['option'])) && $poll['graph'] == 'yes' && $started == 'yes') {
if (((isset ($_REQUEST['results']) && $poll['results'] == 'yes' && ($voteip != 'yes' | $votecookies != 'yes')) | !isset ($_REQUEST['results'])) && $started == 'yes') {
$option = mysql_query ("SELECT options, votes, images, order_id FROM options WHERE pollid='$whatpoll' ORDER BY order_id ASC");
$total = mysql_fetch_assoc (mysql_query ("SELECT SUM(votes) AS total FROM options WHERE pollid='$whatpoll'"));
?>
<table width="100%" border="0" cellspacing="0" cellpadding="2" class="border">
<td height="25" colspan="2"><b><?= $poll['title']; ?></b></td>
</tr>
<?php
while ($optionrows = mysql_fetch_array ($option)) {
@$percent = round (($optionrows['votes'] / $total['total']) * 100);
if ($optionrows['images'] == 'random') {
if ($handle = opendir ($dir2)) {
while (false !== ($file = readdir ($handle))) {
if ($file != '.' && $file != '..') {
$files[] = $file;
}
}
shuffle ($files);
}
$rand = rand (0, (count ($files) - 1));
$optionrows['images'] = $files[$rand];
}
?>
<tr class="text">
<td width="100%" height="25"><?= $optionrows['options']; ?>
<br />
<img src="<?= $dir2; ?>/<?= $optionrows['images']; ?>" width="<?= ($percent * $width) + 10; ?>" height="<?= $height; ?>" alt="<?= $optionrows['options']; ?>"><td width="100%"><b><td width="100%"><?= $percent; ?>%</b></td>
</tr>
<?php } ?>
<tr class="text">
<td height="25"><?php if ($poll['resultsvotes'] == "yes") { ?><b>Totaal <?= $total['total']; ?> stemmen</b>
<?php } if (isset ($_REQUEST['results'])) {?><br><?php } ?></td>
</tr>
</table>
<img src="images/layout/marker.gif" alt="" style="margin-right:3px; margin-left:1px; vertical-align:middle"><b><a href="?id=manofthematch">Breng ook je stem uit!</a></b>
<?php
}
}
} else {
?>
<div align="center" class="text"><br /><b>Er zijn momenteel geen polls.<a href="admin/index.php" class="text">maak</a> een poll.</div>
<?php } if ($totalpolls > 0 && $poll['voting'] == 'no' && $poll['graph'] == 'no') { ?>
<div align="center" class="text">Helaas kunt u niet stemmen of de resultaten bekijken van deze poll</div>
<?php } if ($totalpolls > 0 && $poll['voting'] == 'yes' && $poll['graph'] == 'no' && isset ($_REQUEST['option'])) { ?>
<div align="center" class="text">Bedankt om te stemmen op de poll.</div>
<?php } if ($totalpolls > 0 && $poll['voting'] == 'yes' && $poll['graph'] == 'no' && ($voteip == 'no' | $votecookies == 'no') && !isset ($_REQUEST['option'])) { ?>
<div align="center" class="text">Sorry, je kunt niet stemmen op deze poll<b><?= $polls['title']; ?></b></div>
<?php } if ($totalpolls > 0 && $poll['results'] == 'no' && isset ($_REQUEST['results'])) { ?>
<div align="center" class="text">Sorry, je kunt niet de resultaten bekijken van deze poll<b><?= $polls['title']; ?></b></div>
<?php } ?>