Ver Mensaje Individual
  #4 (permalink)  
Antiguo 21/01/2008, 20:46
okram
Invitado
 
Mensajes: n/a
Puntos:
Re: Cómo limitar carga de datos

Cita:
Iniciado por GatorV Ver Mensaje
Código PHP:
$limit = 10;
$count = 1;
foreach(
$noticia->fetch_array() as $row) {
    echo 
' 
    <li><a href="' 
. $row['url'] . '" target="_blank">' . trim($row['text']) . '</a></li>';
    
$count++;
    if( 
$count == $limit ) break;
} 
Saludos.
Creo que el valor inicial de $count debe ser 0, y $break; no debe llevar $. Errores de tipeo solamente:

Código PHP:
$limit = 10;
 
$count = 0;
foreach(
$noticia->fetch_array() as $row) {
    echo 
' 
    <li><a href="' 
. $row['url'] . '" target="_blank">' . trim($row['text']) . '</a></li>';
    if( 
$count == $limit ) $break;
    
$count++;
} 
Un saludo,