Sum fuction !

Junior Spellweaver
Joined
Jan 25, 2012
Messages
114
Reaction score
4
I whant to make Top 10 Voters and i need to sum() my vote_count

I test eny tutorials but not luck !

$Status=mssql_query("select TOP 10 SUM(vote_count),vote_acc from TABLE order by vote_count desc");
while($row=mssql_fetch_assoc($Status)){
$vote_count=$row['vote_count'];
$Name=$row['vote_acc'];


<td class="test"><div class="NameOfCaracter"><?=$Name;?></div></td>
<td class="test"><div align="center"><?=$vote_count;?></div></td>

I this first problmes is mssql_fetch_assoc here ! i thick mssql_fetch_array is corecty !

So whant i need to fixed to count my SUM all points in 1 name !

Thx
 
I whant to make Top 10 Voters and i need to sum() my vote_count

I test eny tutorials but not luck !

$Status=mssql_query("select TOP 10 SUM(vote_count),vote_acc from TABLE order by vote_count desc");
while($row=mssql_fetch_assoc($Status)){
$vote_count=$row['vote_count'];
$Name=$row['vote_acc'];


<td class="test"><div class="NameOfCaracter"><?=$Name;?></div></td>
<td class="test"><div align="center"><?=$vote_count;?></div></td>

I this first problmes is mssql_fetch_assoc here ! i thick mssql_fetch_array is corecty !

So whant i need to fixed to count my SUM all points in 1 name !

Thx

Sorry what?!
I don't understand what you're trying to do. - If you're trying to take the top ten's ______ and add them all together do something like.
PHP:
<?php
$second_number = //Whatever? ;
$first_number = //Whatever? ;
$sum_total = $second_number * $first_number;
echo $sum_total;
?>
 
Code:
<?php
$q = mssql_query("SELECT TOP 10 SUM(vote_count) AS COUNT, vote_acc FROM TABLE ORDER BY vote_count DESC");

while($row = mssql_fetch_array($q))
	echo '<td class="test"><div class="NameOfCaracter">'.$row['vote_acc'].'</div></td>
		  <td class="test"><div align="center">'.$row['COUNT'].'</div></td>';
?>

Edit: just thought about it, what are you summing lol?
 
Yes jMerliN I want to summing my vote_count ! ID table is vote_acc because is muweb vote 0.2 ! i want to procedure to count my vote_count and the base of this is vote_acc !

DEMO

KrYsSu - Sum fuction ! - RaGEZONE Forums
 
Last edited:
Since I'm not really good with MSSQL, I had to execute 2 queries.
Code:
<?php
$q = mssql_query("SELECT TOP 10 vote_acc FROM TABLE ORDER BY vote_count DESC");

while($row = mssql_fetch_array($q))
{
        $q2 = mssql_query("SELECT SUM(vote_count) AS COUNT FROM vote_count WHERE vote_acc = '".$row['vote_acc']."'");

	echo '<td class="test"><div class="NameOfCaracter">'.$row['vote_acc'].'</div></td>
		  <td class="test"><div align="center">'.mssql_result($q, 0, 'COUNT').'</div></td>';
}
?>
 
Vusion i try your explain but don`t working No have error but not working !

Okey i will share my code too see what is about !

<?php
$Status=mssql_query("select TOP 10 vote_count,vote_acc from MuOnline.dbo.MuWeb_des_vote_count_acc order by vote_count desc");
while($row=mssql_fetch_assoc($Status)){
$vote_count=$row['vote_count'];
$NameOfCarachter=$row['vote_acc'];

if($Status2 == 1) {$on_off = "<img src='template/BFMDeVelopeR/images/online/verde.gif'/>";} else {$on_off = "<img src='template/BFMDeVelopeR/images/online/rosu.gif'/>";}
?>

I add here to convert vote_acc to characters ! I hide account id and convert to name of Caracter !

<?
$OnlineAccount = mssql_fetch_row(mssql_query("SELECT GameIDC,Id FROM MuOnline.dbo.AccountCharacter WHERE Id='".$NameOfCarachter."'"));
$Name = $OnlineAccount[0];
?>


And in final i make " ECHO "

<tr>
<div class="count"><?=++$count;?></div>
<?
$Images = array("<img src='template/BFMDeVelopeR/RankTime/Legend.png'/>", "<img src='template/BFMDeVelopeR/RankTime/Veteran.png'/>", "<img src='template/BFMDeVelopeR/RankTime/3star.png'/>", "<img src='template/BFMDeVelopeR/RankTime/2star.png'/>", "<img src='template/BFMDeVelopeR/RankTime/1star.png'/>", "<img src='template/BFMDeVelopeR/RankTime/GunnerySergeant.png'/>", "<img src='template/BFMDeVelopeR/RankTime/Sergeant.png'/>", "<img src='template/BFMDeVelopeR/RankTime/Corporal.png'/>", "<img src='template/BFMDeVelopeR/RankTime/Private.png'/>", "<img src='template/BFMDeVelopeR/RankTime/Apprentice.png'/>");
?>
<td class="gradee"><div align="center"><?=$Images[$count-1];?></div></td>
<td class="gradee"><div class="NameOfCaracter"><?=$Name;?></div></td>
<td class="gradee"><div align="center"><?=$vote_count;?></div></td>
<td class="gradee"><div align="center"> <?=$LastOnline;?></div></td>
<td class="onlineoffline" align="center"><? echo "$on_off"; ?></td>

</tr>
<?
}
?>
 
Vusion i try your explain but don`t working No have error but not working !

Okey i will share my code too see what is about !



I add here to convert vote_acc to characters ! I hide account id and convert to name of Caracter !




And in final i make " ECHO "

From what I can see your not even echoing the things that should be echoed. Don't put PHP inside the html, either and don't use <? or ?>
 
From what I can see your not even echoing the things that should be echoed. Don't put PHP inside the html, either and don't use <? or ?>

Go read more about php before you post. What he's doing is absolutely correct.
PHP: Escaping from HTML - Manual

If only I knew more about MUOnline's database, I would have helped ya.

EDIT.

You could use a subquery to get "GameIDC" inside the first query.
 
Last edited:
Ok in database will find !

KrYsSu - Sum fuction ! - RaGEZONE Forums

PS:

You could use a subquery to get "GameIDC" inside the first query.

GEMIDC is the converting of vote_acc to ID mu___id


</Jayden>

The echo you will type but not every time ! Echo is a printing in your table but i call <?=$NameOfFunction;?>

Look in my demo will se the table is printing correct.
 
Back