Hola quisiera solicitar de su apoyo, estoy mostrando de mi DB, una tabla en la cual logre sumar y calcular el promedio (con un juego de registros en dreamweaver),
Sin embargo ahora no logro sumar las filas por lo que requiero de su apoyo.
<?php require_once('../Connections/local.php'); ?>
<?phpif (!function_exists("GetSQLValueString")) {function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue;}}$currentPage = $_SERVER["PHP_SELF"];$maxRows_cant_cursos_andes = 10;$pageNum_cant_cursos_andes = 0;if (isset($_GET['pageNum_cant_cursos_andes'])) { $pageNum_cant_cursos_andes = $_GET['pageNum_cant_cursos_andes'];}$startRow_cant_cursos_andes = $pageNum_cant_cursos_andes * $maxRows_cant_cursos_andes;mysql_select_db($database_local, $local);$query_cant_cursos_andes = "SELECT * FROM `cantidad de cursos region andes`";$query_limit_cant_cursos_andes = sprintf("%s LIMIT %d, %d", $query_cant_cursos_andes, $startRow_cant_cursos_andes, $maxRows_cant_cursos_andes);$cant_cursos_andes = mysql_query($query_limit_cant_cursos_andes, $local) or die(mysql_error());$row_cant_cursos_andes = mysql_fetch_assoc($cant_cursos_andes);if (isset($_GET['totalRows_cant_cursos_andes'])) { $totalRows_cant_cursos_andes = $_GET['totalRows_cant_cursos_andes'];} else { $all_cant_cursos_andes = mysql_query($query_cant_cursos_andes); $totalRows_cant_cursos_andes = mysql_num_rows($all_cant_cursos_andes);}$totalPages_cant_cursos_andes = ceil($totalRows_cant_cursos_andes/$maxRows_cant_cursos_andes)-1;$queryString_cant_cursos_andes = "";if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "pageNum_cant_cursos_andes") == false && stristr($param, "totalRows_cant_cursos_andes") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_cant_cursos_andes = "&" . htmlentities(implode("&", $newParams)); }}$queryString_cant_cursos_andes = sprintf("&totalRows_cant_cursos_andes=%d%s", $totalRows_cant_cursos_andes, $queryString_cant_cursos_andes);$totales = $row_cant_cursos_andes;session_start();require("conexion.php");$usu=$_SESSION['usuario'];$consulta11=mysql_query("SELECT * FROM usuario where usuario='$usu' ") or die(mysql_error());$pacientes=mysql_fetch_array($consulta11);$usu=$pacientes['nombre']." ".$pacientes['apellido'];?>
<!doctype html>
<html>
<head>
</head>
<body>
<table border="1" align="center" bgcolor="#CBCBCB" width="1280">
<tr bgcolor="#DBDBDB">
<td><strong>Región</strong></td>
<td><strong>Año</strong></td>
<td><strong>Enero</strong></td>
<td><strong>Febrero</strong></td>
<td><strong>Marzo</strong></td>
<td><strong>Abril</strong></td>
<td><strong>Mayo</strong></td>
<td><strong>Junio</strong></td>
<td><strong>Julio</strong></td>
<td><strong>Agosto</strong></td>
<td><strong>Septiembre</strong></td>
<td><strong>Octubre</strong></td>
<td><strong>Noviembre</strong></td>
<td><strong>Diciembre</strong></td>
<td><strong>Total</strong></td>
<td><strong>Promedio</strong></td>
<td><strong>Actualizar</strong></td>
</tr>
<?php do { ?>
<tr>
<td bgcolor="#E0E0E0"><strong><?php echo $row_cant_cursos_andes['Region']; ?>
</a></strong></td>
<td><?php echo $row_cant_cursos_andes['year']; ?>
</td>
<td><?php echo $row_cant_cursos_andes['Enero']; ?>
</td>
<td><?php echo $row_cant_cursos_andes['Febrero']; ?>
</td>
<td><?php echo $row_cant_cursos_andes['Marzo']; ?>
</td>
<td><?php echo $row_cant_cursos_andes['Abril']; ?>
</td>
<td><?php echo $row_cant_cursos_andes['Mayo']; ?>
</td>
<td><?php echo $row_cant_cursos_andes['Junio']; ?>
</td>
<td><?php echo $row_cant_cursos_andes['Julio']; ?>
</td>
<td><?php echo $row_cant_cursos_andes['Agosto']; ?>
</td>
<td><?php echo $row_cant_cursos_andes['Septiembre']; ?>
</td>
<td><?php echo $row_cant_cursos_andes['Octubre']; ?>
</td>
<td><?php echo $row_cant_cursos_andes['Noviembre']; ?>
</td>
<td><?php echo $row_cant_cursos_andes['Diciembre']; ?>
</td>
<td><strong> <?php echo $suma=$row_cant_cursos_andes['Enero']+ $row_cant_cursos_andes['Febrero']+ $row_cant_cursos_andes['Marzo']+ $row_cant_cursos_andes['Abril']+ $row_cant_cursos_andes['Mayo']+ $row_cant_cursos_andes['Junio']+ $row_cant_cursos_andes['Julio']+ $row_cant_cursos_andes['Agosto']+ $row_cant_cursos_andes['Septiembre']+ $row_cant_cursos_andes['Octubre']+ $row_cant_cursos_andes['Noviembre']+ $row_cant_cursos_andes['Diciembre'] ?>
</strong></td>
<td><strong> <?php $prom=($row_cant_cursos_andes['Enero']+ $row_cant_cursos_andes['Febrero']+ $row_cant_cursos_andes['Marzo']+ $row_cant_cursos_andes['Abril']+ $row_cant_cursos_andes['Mayo']+ $row_cant_cursos_andes['Junio']+ $row_cant_cursos_andes['Julio']+ $row_cant_cursos_andes['Agosto']+ $row_cant_cursos_andes['Septiembre']+ $row_cant_cursos_andes['Octubre']+ $row_cant_cursos_andes['Noviembre']+ $row_cant_cursos_andes['Diciembre'])/12; echo $prom= round($prom, 1) ?>
</strong></td>
<td><strong><form action="act_cant_cursos/act_cursos_andes.php?year=<?php echo $row_cant_cursos_andes['year']; ?>
" method="post">
<input type="submit" value="Actualizar" style="background-color:#8FB9DA"/> </form></strong>
</td>
</tr>
<?php } while ($row_cant_cursos_andes = mysql_fetch_assoc($cant_cursos_andes)); ?>
</table>
<!-- ------------------------------- Aqui quisiera realizar la suma----------------------------------------- -->
<?php do { ?>
<?php $totales["year"]+=$row_cant_cursos_andes['year']; ?>
<?php $totales["Enero"]+=$row_cant_cursos_andes['Enero']; ?>
<?php $totales["Febrero"]+=$row_cant_cursos_andes['Febrero']; ?>
<?php $totales["Marzo"]+=$row_cant_cursos_andes['Marzo']; ?>
<?php $totales["Abril"]+=$row_cant_cursos_andes['Abril']; ?>
<?php $totales["Mayo"]+=$row_cant_cursos_andes['Mayo']; ?>
<?php $totales["Junio"]+=$row_cant_cursos_andes['Junio']; ?>
<?php $totales["Julio"]+=$row_cant_cursos_andes['Julio']; ?>
<?php $totales["Agosto"]+=$row_cant_cursos_andes['Agosto']; ?>
<?php $totales["Septiembre"]+=$row_cant_cursos_andes['Septiembre']; ?>
<?php $totales["Octubre"]+=$row_cant_cursos_andes['Octubre']; ?>
<?php $totales["Noviembre"]+=$row_cant_cursos_andes['Noviembre']; ?>
<?php $totales["Diciembre"]+=$row_cant_cursos_andes['Diciembre']; ?>
<table border="1" align="center" bgcolor="#CBCBCB" width="1280">
</tr>
<td><strong>Total</strong></td>
<td><?php echo $totales["year"]; ?>
</td>
<td><?php echo $totales["Enero"]; ?>
</td>
<td><?php echo $totales["Febrero"]; ?>
</td>
<td><?php echo $totales["Marzo"]; ?>
</td>
<td><?php echo $totales["Abril"]; ?>
</td>
<td><?php echo $totales["Mayo"]; ?>
</td>
<td><?php echo $totales["Junio"]; ?>
</td>
<td><?php echo $totales["Julio"]; ?>
</td>
<td><?php echo $totales["Agosto"]; ?>
</td>
<td><?php echo $totales["Septiembre"]; ?>
</td>
<td><?php echo $totales["Octubre"]; ?>
</td>
<td><?php echo $totales["Noviembre"]; ?>
</td>
<td><?php echo $totales["Diciembre"]; ?>
</td>
<td>Total</td>
<td>Promedio</td>
<td>Actualizar</td>
</tr>
</table>
<?php } while ($totales = $row_cant_cursos_andes); ?>
<!-- -------------------------------Termina Suma de Filas----------------------------------------- -->
<p align="center">Gerencia de Capacitación ®</p>
</body>
</html>
<?php mysql_free_result($cant_cursos_andes);?>