try this
$sql="SELECT SUM(amount)as sum FROM `taffiliate` WHERE affid='MW001'";
$result= mysqli_query($con, $sql) or die(mysqli_error($con));
while ($row= mysqli_fetch_array($result))
{
$y= $row['sum'].'<br>';
}
you can use where condition as you want i just gave one example, for MW001, the total will be 31