Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/11/2012, 14:56
Avatar de dvbeaumont
dvbeaumont
 
Fecha de Ingreso: marzo-2011
Ubicación: Caracas
Mensajes: 145
Antigüedad: 13 años, 1 mes
Puntos: 1
Pregunta Agrupar registros

Hola Tengo el siguiente codigo:

Código PHP:
$result_p=mysql_query("select puntuacion,COUNT(puntuacion) from t_motivo  GROUP BY puntuacion",$link);     
while(
$row mysql_fetch_array($result_p)){
    if(
$row["puntuacion"]== 1)
    {
    
$puntuacion"Muy Bajo";
    }
    elseif(
$row["puntuacion"]== 2)
    {
    
$puntuacion"Bajo";
    }
    elseif(
$row["puntuacion"]== or $row["puntuacion"]== 4)
    {
    
$puntuacion"Moderado";
    }
    elseif(
$row["puntuacion"]>= 5)
    {
    
$puntuacion="Alto";
    }    
            echo 
"['".$puntuacion." - Total: ".$row['COUNT(puntuacion)'] ." ' ,"$row['COUNT(puntuacion)'] ."]";
            echo 
",";
            } 
Originalmente hace lo siguiente:

Los registros por puntuacion del 1 al 4 los coloca de esta forma

ID | puntuacion
1 | 2
2 | 3
3 | 5
4 | 10
5 | 1
6 | 1
8 | 2

Entonces sería:

Puntuacion: 1 = 2 registros
Puntuacion: 2 = 2 registros
Puntuacion: 3 y 4 = 1 registro (Pero si hubiese uno con 4 no lo agrupa sino q imprime otro registro)
Puntuacion: 5 y mayor que 5 = 2 registros (Pero imprime dos veces, deseo es que imprima una sola vez y cuente que hay 2 registros)

Espero puedan ayudarme.

Gracias
__________________
Sé parte de nuestro mundo creativo.

http://bbcreativos.com