Ver Mensaje Individual
  #11 (permalink)  
Antiguo 20/08/2010, 07:01
Avatar de GatorV
GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Sumar arrays...

@andrewp Te recomiendo leer realmente un libro básico de arreglos y PHP ya que estas cometiendo muchos errores, cuando lo podrías solucionar con algo tan simple:
Código PHP:
Ver original
  1. $consulta = "SELECT tipo, sum(valor), COUNT(unidades) FROM miTabla GROUP BY tipo;";
  2. $resultado = mysql_query($consulta) or die (mysql_error());
  3. $total = array();
  4. while ($col = mysql_fetch_array($resultado, MYSQL_NUM)) {
  5.               $suma = $col[1];
  6.               $conteo = $col[2];
  7.  
  8.               $total[] = ($suma / $conteo);
  9. }
  10. echo array_sum($total);

Saludos.