Trying to combine two records (add) and display top10???
Posted: Tue Jun 08, 2010 10:21 am
Hi, i'm working on a site that is currently having a voting competition. There are three rounds of voting, we are currently on the second. I've come up with this code so far and it works on the test site (so it seems) but not on the live site. It's supposed to count "votesSubmitted+bonusvotesSubmitted" and display the total, then list the top ten on the home page. What is happening is it isn't ordering them from most votes down. Here's the snippit: http://pastie.org/996396
Code: Select all
<div id="competition_table">
<table>
<?php
$i=1;
$query_voters="SELECT id, nickname, votesSubmitted, bonusvotesSubmitted, status FROM ".DB_DATABASE.".accounts_2010 WHERE (accounts_2010.status='Voter' OR accounts_2010.status='Under Review' OR accounts_2010.status='Contestant') AND accounts_2010.nickname!='' ORDER BY (votesSubmitted+bonusvotesSubmitted) DESC, dateCreatedTimestamp ASC LIMIT 10";
$result_voters=mysql_query($query_voters);
while ($record_voters=mysql_fetch_object($result_voters))
{
?>
<tr>
<td width="20"><?=$i?></td>
<td width="350"><?=$record_voters->nickname?></td>
<td width="20"><?=$record_voters->votesSubmitted+bonusvotesSubmitted?></td>
</tr>
<?php
$i++;
}
?>
</table>