Ver Mensaje Individual
  #10 (permalink)  
Antiguo 17/04/2012, 04:17
Avatar de zalito12
zalito12
 
Fecha de Ingreso: noviembre-2011
Ubicación: Coruña, España
Mensajes: 430
Antigüedad: 12 años, 5 meses
Puntos: 67
Respuesta: Horror en arrays. Comparar valores iguales.

¿Lo has comprobado o no?
Si los ordenas por id estas líneas que puse:
Código PHP:
  if($registro['id'] != $idAnt){
    echo 
'<table align=center border=2>';
  }
  if(
$registro['id'] != $idAnt){
    echo 
'</table>';
  }
  
$idAnt $registro['id']; 
Deberían evitar que te cree una tabla nueva para cada id

Fallo mío, me equivoque al posicionar el final de la tabla :S
Ahora te actualizo el código

Le he puesto un pequeño parche xD, debería funcionar:
Código PHP:
<?php
$resultado
mysql_query("select averias.id_averia as id, fecha, desc_averia, num_pieza, unidades from averias inner join ave_rep on averias.id_averia=ave_rep.id_averia where fecha between '$v1' and '$v2' order by id_averia",$c);
$comprueba=mysql_num_rows($resultado);
$idAnt '';
echo 
'<table border="0">';
while (
$registro=mysql_fetch_assoc($resultado)){
  if(
$registro['id'] != $idAnt){
    echo 
'</table><table align=center border=2>';
  }
  
?>
    <FORM name="modificar" method="POST" action="consultaaverias2.php">
    <tr>
        <td>ID de la averia</td>
        <td><input type="text" name="id_averia" value="<?php echo $registro['id']; ?>"></td>
    </tr>
    <br />        
    <tr>
       <td>Fecha Averia</td>
       <td><input type="text" name="fecha" value="<?php echo date('d/m/Y',strtotime($registro['fecha'])); ?>"></td>
    </tr>
    <br />
    <tr>
       <td>Descripción de la averia</td>
       <td><input type="text" name="desc_averia" value="<?php echo $registro['desc_averia']; ?>"></td>
    </tr>
    <br />    
    <tr>
       <td>Referencia de la Pieza</td>
       <td><input type="text" name="num_pieza" value="<?php echo $registro['num_pieza']; ?>"></td>
    </tr>
    <br />
    <tr>
       <td>Cantidad</td>
       <td><input type="text" name="unidades" value="<?php echo $registro['unidades']; ?>"></td>
    </tr>    
    <br />
       <td align=center><input type='submit' value='Modificar'></td>
    </tr>
    </form>
    <?php
  $idAnt 
$registro['id']; 
}
?> 
</table>

Última edición por zalito12; 17/04/2012 a las 04:39