Ver Mensaje Individual
  #8 (permalink)  
Antiguo 20/02/2010, 10:54
Avatar de zeuzft
zeuzft
 
Fecha de Ingreso: junio-2009
Ubicación: peru
Mensajes: 358
Antigüedad: 14 años, 9 meses
Puntos: 2
Respuesta: como Limitar un while a 6 resultados??

se imprime en una sola fila
Código PHP:
            echo "<table border='0' cellspacing='2' cellpadding='0'>";
            
$consulta=mysql_query("SELECT * FROM cancion order by can_id desc limit 0,6");
            
$columnaActual=1;
            
$columnasTotales=3;
            while (
$a=mysql_fetch_array($consulta))
            {
            
$cont ++;
            
$id=$a['can_id'];
            
$cancion=$a['can_nom'];
            
$artista=$a['can_art'];
            
$foto="musica1/".$id.".jpg";
            if (
file_exists($foto))
                {
                    
$s="<img border='0' height='80' width='60' alt='$cancion $artista' src=".$foto." />";
                }
            else{
                    
$s="<img border='0' height='80' width='60' alt='$cancion $artista' src='imagenes/Vista147.png' />";
                }
            if(
$cont==6) { break; }
            if(
columnaActual==1) { echo "<tr>"; } elseif(columnaActual==3) { echo "</tr>"; } 
            echo 
"<td>".$s."</td>";
            
//echo "<tr><td>".$s."</td><td>".$s."</td><td>".$s."</td></tr>";
            
$columnaActual++;
            }
            echo 
"</table>"