Ver Mensaje Individual
  #5 (permalink)  
Antiguo 24/02/2010, 07:17
Avatar de CHuLoSoY
CHuLoSoY
 
Fecha de Ingreso: febrero-2002
Ubicación: Ribeira (Galicia)
Mensajes: 1.900
Antigüedad: 22 años, 2 meses
Puntos: 29
Respuesta: Agrupar registros por años

Para tu primera pregunta
Código PHP:
Ver original
  1. <?php
  2. require"../conexion.php";
  3.  
  4. $consulta8="SELECT year FROM tabla11 GROUP BY year ORDER BY year DESC";
  5. $resultado8 = mysql_query($consulta8,$conexion) or die(mysql_error());
  6.          $row1 = mysql_fetch_array($resultado8) ;
  7. echo "Año ".$row1['year'];
  8.  
  9. while($row1)
  10.     {  
  11.     $consulta9="SELECT * FROM tabla11 WHERE year = '".$row["year"]."' ORDER BY year DESC";
  12.     $resultado9 = mysql_query($consulta9,$conexion) or die(mysql_error());
  13.     $row = mysql_fetch_array($resultado8);
  14.    
  15.     echo "<table border='1'>";
  16.     echo "<tr>";
  17.     echo "<td>".$row['codigo']."</td>";                                        
  18.     echo "<td >".$row['fechaprueba']."</td>";
  19.     echo "<td>".($row['tipo'])."</td>";
  20.     echo "<td >".($row['resultado'])."</td>";
  21.     echo "<td><a href='" .$row['enlace']."'><u>Ver</u></a></td>";
  22.     echo "<td>".($row['conclusiones'])."</td>";
  23.     echo "<td>".($row['propuestas'])."</td>";
  24.     echo "</tr>";
  25.     echo "</table>";
  26.  }
  27. include"../cerrar_conexion.php";
  28. ?>
o algo parecido.
A tu segunda pregunta:

Código PHP:
Ver original
  1. $sql="SELECT * FROM tabla WHERE user='".$user."'";
  2. $cosas=mysql_query($sql) or die ("error");
  3.  
  4. $numeroresultados=mysql_num_rows($cosas);
  5.  
  6. if($numeroresultados==0)   { echo "USER SIN DATOS"; }
__________________
ESQUIO Dominios y Hosting
Las mejores características con los mejores precios.