Este es mmi codigo para contar o sumar los datos
<html>
<title></title>
<head></head>
<body>
<table> <tr>
<td>Alumnos Desestores </td>
<td>
<?php
extract($_POST);
$desertores= "select count(i.No_Control) as total, i.estado, i.Id_Carrera, g.Id_Carrera, g.Id_Grupo, g.Clave_Tutor, g.Semestre_Ingreso
from indicador1 as i, grupo as g
where i.estado='BD5' and i.Id_Carrera=g.Id_Carrera and g.Id_Carrera='$carrera' and g.Id_Grupo='1' and g.Semestre_Ingreso='$periodo'";
mysql_query($desertores, $con) or die (mysql_error());
$desertores2= "select count(i.No_Control) as total2, i.estado, i.Id_Carrera, g.Id_Carrera, g.Id_Grupo, g.Clave_Tutor, g.Semestre_Ingreso
from indicador1 as i, grupo as g
where i.estado='BD6' and i.Id_Carrera=g.Id_Carrera and g.Id_Carrera='$carrera' and g.Id_Grupo='1' and g.Semestre_Ingreso='$periodo'";
mysql_query($desertores2, $con) or die (mysql_error());
$desertores3= "select count(i.No_Control) as total3, i.estado, i.Id_Carrera, g.Id_Carrera, g.Id_Grupo, g.Semestre_Ingreso
from indicador1 as i, grupo as g
where i.estado='BD7' and i.Id_Carrera=g.Id_Carrera and i.Id_Carrera='$carrera' and g.Id_Grupo='1' and g.Semestre_Ingreso='$periodo'";
mysql_query($desertores3, $con) or die (mysql_error());
$desertores4= "select count(i.No_Control) as total4, i.estado, i.Id_Carrera, g.Id_Carrera, g.Id_Grupo, g.Semestre_Ingreso
from indicador1 as i, grupo as g
where i.estado='BD7' and i.Id_Carrera=g.Id_Carrera and i.Id_Carrera='$carrera' and g.Id_Grupo='1' and g.Semestre_Ingreso='$periodo'";
mysql_query($desertores4, $con) or die (mysql_error());
$desertores5= "select i.estado2, i.Id_Carrera, g.Id_Carrera, g.Id_Grupo, g.Semestre_Ingreso, count(i.No_Control) as total5
from indicador2 as i, grupo as g
where g.Id_Carrera=i.Id_Carrera and i.Id_Carrera='$carrera' and i.estado2='BD5' and g.Id_Grupo='1' and g.Semestre_Ingreso='$periodo'";
mysql_query($desertores5, $con) or die (mysql_error());
$desertores6= "select i.estado2, i.Id_Carrera, g.Id_Carrera, g.Id_Grupo, g.Clave_Tutor and g.Semestre_Ingreso, count(i.No_Control) as total6
from indicador2 as i, grupo as g
where g.Id_Carrera=i.Id_Carrera and i.Id_Carrera='$carrera' and g.Id_Grupo='1' and i.estado2='BD6' and g.Semestre_Ingreso='$periodo'";
mysql_query($desertores6, $con) or die (mysql_error());
$desertores7= "select i.estado2, i.Id_Carrera, g.Id_Carrera, g.Id_Grupo, g.Semestre_Ingreso, count(i.No_Control) as total7
from indicador2 as i, grupo as g
where i.Id_Carrera=g.Id_Carrera and i.Id_Carrera='$carrera' and g.Id_Grupo='1' and i.estado2='BD7' and g.Semestre_Ingreso='$periodo'";
mysql_query($desertores7, $con) or die (mysql_error());
$desertores8= "select i.estado2, i.Id_Carrera, g.Id_Carrera, g.Id_Grupo, g.Semestre_Ingreso, count(i.No_Control) as total8
from indicador2 as i, grupo as g
where i.estado2='BD8' and i.Id_Carrera=g.Id_Carrera and i.Id_Carrera='$carrera' and g.Id_Grupo='1' and g.Semestre_Ingreso='$periodo'";
mysql_query($desertores8, $con) or die (mysql_error());
$desertores9= "select count(i.No_Control) as total9, i.estado3, i.Id_Carrera, g.Id_Carrera, g.Id_Grupo, g.Semestre_Ingreso
from indicador3 as i, grupo as g
where i.estado3='BD5' and i.Id_Carrera=g.Id_Carrera and i.Id_Carrera='$carrera' and g.Id_Grupo='1' and g.Semestre_Ingreso='$periodo'";
mysql_query($desertores9, $con) or die (mysql_error());
$desertores10= "select count(i.No_Control) as total10, i.estado3, i.Id_Carrera, g.Id_Carrera, g.Id_Grupo, g.Semestre_Ingreso
from indicador3 as i, grupo as g
where i.estado3='BD6' and i.Id_Carrera=g.Id_Carrera and i.Id_Carrera='$carrera' and g.Id_Grupo='1' and g.Semestre_Ingreso='$periodo'";
mysql_query($desertores10, $con) or die (mysql_error());
$desertores11= "select count(i.No_Control) as total11, i.estado3, i.Id_Carrera, g.Id_Carrera, g.Id_Grupo, g.Semestre_Ingreso
from indicador3 as i, grupo as g
where i.estado3='BD7' and i.Id_Carrera=g.Id_Carrera and i.Id_Carrera='$carrera' and g.Id_Grupo='1' and g.Semestre_Ingreso='$periodo'";
mysql_query($desertores11, $con) or die (mysql_error());
$desertores12= "select count(i.No_Control) as total12, i.estado3, i.Id_Carrera, g.Id_Carrera, g.Id_Grupo, g.Semestre_Ingreso
from indicador3 as i, grupo as g
where i.estado3='BD8' and i.Id_Carrera=g.Id_Carrera and i.Id_Carrera='$carrera' and g.Id_Grupo='1' and g.Semestre_Ingreso='$periodo'";
mysql_query($desertores12, $con) or die (mysql_error());
$desertores13= "select count(i.No_Control) as total13, i.estado4, i.Id_Carrera, g.Id_Carrera, g.Id_Grupo, g.Semestre_Ingreso
from indicador4 as i, grupo as g
where i.estado4='BD5' and i.Id_Carrera=g.Id_Carrera and i.Id_Carrera='$carrera' and g.Id_Grupo='1' and g.Semestre_Ingreso='$periodo'";
mysql_query($desertores13, $con) or die (mysql_error());
$desertores14= "select count(i.No_Control) as total14, i.estado4, i.Id_Carrera, g.Id_Carrera, g.Id_Grupo, g.Semestre_Ingreso
from indicador4 as i, grupo as g
where i.estado4='BD6' and i.Id_Carrera=g.Id_Carrera and i.Id_Carrera='$carrera' and g.Id_Grupo='1' and g.Semestre_Ingreso='$periodo'";
mysql_query($desertores14, $con) or die (mysql_error());
$desertores15= "select count(i.No_Control) as total15, i.estado4, i.Id_Carrera, g.Id_Carrera, g.Id_Grupo, g.Semestre_Ingreso
from indicador4 as i, grupo as g
where i.estado4='BD7' and i.Id_Carrera=g.Id_Carrera and i.Id_Carrera='$carrera' and g.Id_Grupo='1' and g.Semestre_Ingreso='$periodo'";
mysql_query($desertores15, $con) or die (mysql_error());
$desertores16= "select count(i.No_Control) as total16, i.estado4, i.Id_Carrera, g.Id_Carrera, g.Id_Grupo, g.Semestre_Ingreso
from indicador4 as i, grupo as g
where i.estado4='BD8' and i.Id_Carrera=g.Id_Carrera and i.Id_Carrera='$carrera' and g.Id_Grupo='1' and g.Semestre_Ingreso='$periodo'";
mysql_query($desertores16, $con) or die (mysql_error());
$desertores17= "select count(i.No_Control) as total17, i.estado5, i.Id_Carrera, g.Id_Carrera, g.Id_Grupo, g.Semestre_Ingreso
from indicador5 as i, grupo as g
where i.estado5='BD5' and i.Id_Carrera=g.Id_Carrera and i.Id_Carrera='$carrera' and g.Id_Grupo='1' and g.Semestre_Ingreso='$periodo'";
mysql_query($desertores17, $con) or die (mysql_error());
$desertores18= "select count(i.No_Control) as total18, i.estado5, i.Id_Carrera, g.Id_Carrera, g.Id_Grupo, g.Semestre_Ingreso
from indicador5 as i, grupo as g
where i.estado5='BD6' and i.Id_Carrera=g.Id_Carrera and i.Id_Carrera='$carrera' and g.Id_Grupo='1' and g.Semestre_Ingreso='$periodo1'";
mysql_query($desertores18, $con) or die (mysql_error());
$desertores19= "select count(i.No_Control) as total19, i.estado5, i.Id_Carrera, g.Id_Carrera, g.Id_Grupo, g.Semestre_Ingreso
from indicador5 as i, grupo as g
where i.estado5='BD7' and i.Id_Carrera=g.Id_Carrera and i.Id_Carrera='$carrera' and g.Id_Grupo='1' and g.Semestre_Ingreso='$periodo'";
mysql_query($desertores19, $con) or die (mysql_error());
$desertores20= "select count(i.No_Control) as total20, i.estado5, i.Id_Carrera, g.Id_Carrera, g.Id_Grupo, g.Semestre_Ingreso
from indicador5 as i, tutorado_indicador as t, grupo as g
where i.estado5='BD8' and i.Id_Carrera=g.Id_Carrera and i.Id_Carrera='$carrera' and g.Id_Grupo='1' and g.Semestre_Ingreso='$periodo'";
mysql_query($desertores20, $con) or die (mysql_error());
$suma12 = ($total + $total2 + $total3 + $total4 + $total5 + $total6 + $total7 + $total8 + $total9 + $total10 + $total11 + $total12 + $total13 + $total14 + $total15 + $total16 + $total17 + $total18 + $total19 + $total20 + $total21 + $total22 + $total23 + $total24 + $total25 + $total26);
echo $suma12; ?> </td>
</tr></td>
</table></body>
</html>
Como puedo hacer para que se realice la suma bien o hay otra forma de sumar datos de las tablas sin realizar tanto codigo, espero me puedan ayudar
![sonrisota](http://static.forosdelweb.com/fdwtheme/images/smilies/xD.png)