Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/03/2010, 19:36
Avatar de Carlmycol
Carlmycol
 
Fecha de Ingreso: diciembre-2007
Ubicación: Los Teques, Venezuela
Mensajes: 240
Antigüedad: 16 años, 4 meses
Puntos: 3
Maximum execution time of 30 seconds exceeded O_o

Estoy haciendo una funcion, que tome un numero X dado por prametro, busque en la tabla registros aleatoreos y los devuelva como un link html, pero no entiendo porque exede el tiempo de ejecucion.. creo que es porque tarda un tiempo alto en generar el numero aleatoreo, o que puede ser?

Código PHP:
function title_randPost($num)
{    
    
$total=get_TotalPost();
    
$link=new mySQL;
    
$link->conectar();
    
    for (
$i=0;$i<$num;)
    {
        
$rand[$i]=rand(1$total);
        
$rands=$rand[$i];
        
$z=0;
        for (
$n=0$n<count($rand); $n++)
        {
            if (
$rand[$n]==$rands)
            {
                
$z=1;
            }
        }
        
        if (
$z==0)
        {
            
$consulta="SELECT * FROM articulos WHERE id=$rands";
            
$result=$link->consultar($consulta);
    
            if (
$link->num_rows($result)>0)
            {
                while(
$row $link->fetch_array($result))
                {
                    
$titulo=$row['titulo'];
                    
$link_title=$row['link'];
            
                }
    
            
$enlace.="<a href=\"index.php?articulo=$link_title\">$titulo</a>";
            
$i++;
            }
        }
    }
    
    
$link->close;
    return 
$enlace;

Saludos