Wij gebruik op onze website xPoll en willen nu dat hij de poll automatisch rankschikt, dus op meest gestemde komt automatisch boven aan:

Hier staat het nu: http://trainerew.nl/index.php?id=motm&sub=archive&poll=19

En dit is het stuk uit de pagina:

	<?php 
	
	@include ("config.php");
	
	$result = mysql_query ("SELECT pollid, title, starts, subdate FROM polls WHERE status='on' AND graph='yes' ORDER BY pollid DESC");
	$numrows = mysql_num_rows ($result);
	
	if (isset ($_REQUEST['poll'])) {
	
		$poll = mysql_fetch_array (mysql_query ("SELECT pollid, title, voting, results, graph, resultsvotes FROM polls WHERE pollid='$_REQUEST[poll]' AND status='on' AND graph='yes'"));
		$option = mysql_query ("SELECT options, votes, images, order_id FROM options WHERE pollid='$_REQUEST[poll]' ORDER BY order_id ASC");
		$total = mysql_fetch_assoc (mysql_query ("SELECT SUM(votes) AS total FROM options WHERE pollid='$_REQUEST[poll]'"));
		
		if (mysql_num_rows (mysql_query ("SELECT pollid FROM polls WHERE pollid='$_REQUEST[poll]'")) == 1) {
	
	?>
	<tr>
		<td align="center">
			<table width="100%" border="0" cellspacing="0" cellpadding="2">
				<tr class="text">
					<td height="25" colspan="3" align="center"><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="4%">&nbsp;</td>
					<td width="96%" height="25"><?= $optionrows['options']; ?>
                    <br>
                    <img src="<?= $dir2; ?>/<?= $optionrows['images']; ?>" width="<?= ($percent * $width) + 10; ?>" height="<?= $height; ?>" alt="<?= $optionrows['options']; ?>"><td><?= $percent; ?>%</td>
1. Alles tussen [code.][/code.] tags (zonder de .)
2. Als het niet via sql kan, zet het in een array en sorteer die...
steen schreef op 14.03.2009 19:37
1. Alles tussen [code.][/code.] tags (zonder de .)
2. Als het niet via sql kan, zet het in een array en sorteer die...


Wij weten nog niet hoe dit werkt, zou je dat kunnen uitleggen?
1. Is voor de opmaak (klik op bewerken en plaats die dingen om de code heen)
2. Een array maken is toch echt basis, bekijk de beginnershandleiding op deze site.
Gedaan.

Reageren