是否有可能在mysql数组结果中添加额外的行然后在smarty中循环?

I'm new to smarty. I tried to loop a mysql query.

My view.php:

require 'libs/smarty.class.php';
$smarty = new Smarty;
include("connection.inc.php");

$query = "SELECT * FROM quickcount group by regency";
$result= mysql_db_query($db, $query, $connection) or
die("query error!");


while($res=mysql_fetch_array($sql))
{
    $data[]=$res;
}

$smarty->assign('qc',$data);
$smarty->display('view.tpl');
?>

My view.tpl:

{section name=i loop=$qc}
<tr>
<td>{$qc[i].regency}</td>          
<td>{$qc[i].vote1}</td>
<td>{$qc[i].vote2}</td>
<td>{$qc[i].vote3}</td>
<td>{$qc[i].vote4}</td>
</tr>
{/section}

Those two files above worked well, but the problem came up when I wanted to add one more column in my output table. Let's say the new column is "total" (vote1+vote2+vote3+vote4).

I tried this in my view.php and failed:

$query = "SELECT * FROM quickcount group by regency";
$result= mysql_db_query($db, $query, $connection) or
die("query error!");

while($res=mysql_fetch_array($sql))
{
    $data[]=$res;
    $vote1 = $res[3];
    $vote2 = $res[4];
    $vote3 = $res[5];
    $vote4 = $res[6];

    $totals=$vote1+$vote2+$vote3+$vote4;
    $total=array($totals);
}

$smarty->assign('qc',$data);
$smarty->assign('total',$total);
$smarty->display('view.tpl');

I want to add percentages as well.

Can anyone help?