Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

MarcosR_

Página não carrega totalmente !

Recommended Posts

Bom dia !

 

Minha página tem uma matriz com aproximadamente 250 elementos.

 

Faço um "for" para carregar os dados mas em um determinado momento os itens não são mais mostrados. A página se comporta como se estivesse sido totalmente carregada, mas faltam itens.

 

Esta página é mostrada dentro de um iframe, mas mesmo carregando separadamente só aparecem alguns itens a mais.

 

O código é este:

 

for ($j=0;$j < count($a);$j++) { 
   $codigo = Trim($a[$j][0]); 

   $lista  = "List".Trim($a[$j][0]);  

   if ($total < 10) {
       $total = "00" . $total;
   } else {
       if($total < 100) {
           $total = "0" . $total; 
       }
   }

   $idimage = $codigo . $contador;

   $link = 'mostra_documentacao_1.php?id=' . $codigo . '∏=' . $codigo;

   echo "<ul style='list-style:none;font-size: 8pt; margin-left:5px; padding:0'>";
   echo '<li id="' . $lista . '">';    
   echo '<img src="'.$HTTP_PATH.'imagens/estrutura/expander_1.png" onClick="show('.$idimage . ')" 
       title="<<-expandir->>" border="0" id="img_'.$idimage.'">';
   if (Tem_Documentacao($codigo) == 'S'){
       echo ' <a href="' . $link . '" target= "iframe_d" alt ="Ver documentação">';			
       echo '<font color= #0000CD>' . $a[$j][0] . ' - ' . $a[$j][1] . '</font>';
       echo '</a>';
   } else {
       echo ' ' . $a[$j][0] . ' - ' . $a[$j][1];
   }    

   echo '</li>';    

   $nivel = 1;
   $total++;

   monta_estru($a[$j][0],1);
   echo "</ul>";
}

 

O que pode ser ?

 

Grato,

 

Marcos

Compartilhar este post


Link para o post
Compartilhar em outros sites

Clique com o botão direito na pagina e em exibir codigo fonte, olhe se está imprimindo algum erro no codigo.

 

Realmente, quase no final da página aparece uma linha com a mensagem:

 

Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\Sistema\lista_documentacao.php on line

 

Tem como resolver isto ?

 

Grato,

 

Marcos

Compartilhar este post


Link para o post
Compartilhar em outros sites

Kra ctz que é um problema com o teu loop, ele está dando um loop infinito e nao termina, então exede o tempo limite de 60 segundos e o php para, tente refazer o cod do teu loop e verifique a logica de novo e veja se corrige o problema.

 

Em último caso, mas em ultimo caso mesmo, altere o tempo limite de 60s para 240s no php.ini e veja se resolve

 

Abraços e até mais

Compartilhar este post


Link para o post
Compartilhar em outros sites

Kra ctz que é um problema com o teu loop, ele está dando um loop infinito e nao termina, então exede o tempo limite de 60 segundos e o php para, tente refazer o cod do teu loop e verifique a logica de novo e veja se corrige o problema.

 

Em último caso, mas em ultimo caso mesmo, altere o tempo limite de 60s para 240s no php.ini e veja se resolve

 

Abraços e até mais

 

Acredito que não seja isto, pois o último item mostrado nem sempre é o mesmo.

 

É que neste loop estou utilizando uma função recursiva para montar as estruturas de produtos (pai,filho,etc) e suaa respectivas documentações, então pode ser este o motivo já que tenho que fazer alguns selects e as estruturas são grandes. Aliás, deu o maior trampo pra montar uma treeview de estruturas, vi vários exemplos na net mas só mesmo o básico (categoria e subcategoria).

 

Se tiverem alguma idéia para que eu possa agilizar este processo agradeço, pois gostaria que o usuário ao acionar a pesquisa a página já viesse com todas as estruturas totalmente carregadas, sem demora. Utilizo SQL SERVER 2005, e tem que ser este mesmo pois as tabelas já estão no sistema utilizado pela empresa (Microsiga).

 

Se por acaso precisarem de um código que monte uma estrutura de produtos, acho que este serve, foi o que utilizei (com algumas adaptações é claro):

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Tree Menu</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style>
li{
	list-style:none;
}
</style>

<script language="javascript">

function show(subCategory, path){
var thesub;
var theimage;
var imageid;
var testingdiv;

thesub = document.getElementById(subCategory);

imageid = "img_"+subCategory;
theimage = document.getElementById(imageid);

testingdiv = document.getElementById("testing");

if(thesub.style.display == 'block'){
	//collapse...
	thesub.style.display = 'none';		
	theimage.src = path+'images/expander.gif';
	//theimage.src = path+'images/fe.gif';
	/*
	//testing...
	testingdiv.style.display = 'block';
	testingdiv.innerHTML = path+'common/parts_manuals/open.gif';
	*/

}else{
	//expand/display...
	thesub.style.display = 'block';
	theimage.src = path+'images/collapser.gif';

	/*
	//testing...
	testingdiv.style.display = 'block';
	testingdiv.innerHTML = path+'common/parts_manuals/up.gif';
	*/
}

}
</script>

</head>

<body onLoad="nokids();">
<?php
//#########################################################################
define('HTTP_PATH', '/localhost/tree_recursive/');

//#########################################################################
## Database Connection
define(DB_HOST, "localhost"); 
 # DB Username
define(DB_USER, "root");
 # DB password
define(DB_PASS, "");
 # DB to select - Database Name
define(DB_NAME, "recursion");

mysql_connect(DB_HOST, DB_USER, DB_PASS) or die(mysql_error());

mysql_select_db(DB_NAME);

//#########################################################################
$children = 0;
$no_children = array();

// $parent is the parent of the children we want to see
// $level is increased when we go deeper into the tree, used to display a nice indented tree
function display_children($parent,$level) {
global $children;
global $no_children;

  	// retrieve all children of $parent
  	$sql = sprintf("SELECT category_name, category_id, category_link
                  FROM categories
                  WHERE parent_id = %d",$parent);

   //echo $sql;   

  	$result = mysql_query($sql);

//if this is a sub category nest the list...
   if($level > 0)
   	echo "<ul id='$parent' style='display:none;'>\n";

  	$list_id='';

// display each child
  	while ($row = mysql_fetch_array($result)) {

  		$children++;
  		$list_id = 'list_'.$children;

      	//display each child
   	echo '<li id="'.$list_id.'">';
   	echo '<a href="#" onClick="show('.$row['category_id'].', \''.$HTTP_PATH.'\')">';
      	echo '<img src="'.$HTTP_PATH.'images/expander.gif" title="expand" border="0" id="img_'.$row['category_id'].'">';
   	echo '<img src="images/fc.gif">';
      	echo '</a>  ';
   	echo $row['category_name'];  //." <span style='color:red;'>".$list_id."</span>";
   	echo '</li>';

      	// call this function again to display this child's children
      	display_children($row['category_id'], $level+1);
   }

  	$child_product = display_products($parent);

  	//if this is a sub category nest the list...
  	if($level > 0)
   	echo "</ul>\n";

$no_children[] =  'list_'.$children;

//if the category has at least one product in it allow us to expand and see that product...
if($child_product)
	array_pop($no_children);

}
//#########################################################################
function display_products($parent) {

 	$child_product = false;

  	// retrieve all children of $parent
  	$sql = sprintf("SELECT product_name, product_id, product_link 
                  FROM products
                  WHERE category_id = %d", $parent);

  	$result = mysql_query($sql);

  	// display each child
  	while ($row = mysql_fetch_array($result)) {		
   	// indent and display the title of this child
      	//echo str_repeat('    ',$level).$row['name']."<br>";//." children:".$children."<br>";
   	echo '<li>';
   	echo '<img src="'.$HTTP_PATH.'images/new.gif" title="product" border="0" id="img_'.$row['category_id'].'" style="margin-top: 
   	5px;">';
      	echo '  ';
   	echo $row['product_name'];
   	echo '</li>';

   	$child_product = true;

  	}
return $child_product;
}
//#########################################################################

echo "<ul style='list-style:none;'>";
display_children('',0);
echo "</ul>";

/*
echo "<pre style='color: red'> ";
print_r($no_children);
echo "</pre>";
*/

?>
<!--<div style="display:block; border: 1px solid red;" id="testing"></div>-->

<script language="javascript" type="text/javascript">
function nokids(){
	var kidnot;
	kidnot = new Array();

	<?php
		for($i=0; $i<count($no_children); $i++){
			print("kidnot.push(\"".$no_children[$i]."\");\n");
		}
	?>

	for(i in kidnot){

		var theid;
		theid = kidnot[i];

		//document.getElementById("testing").innerHTML += theid+", ";
		document.getElementById(kidnot[i]).style.color = "green";
		/*
		var nodelings = document.getElementById(kidnot[i]).childNodes;
		for(var i=0; i<nodelings.length; i++){
			alert(nodelings[i]);
		}
		*/
	}
}
</script>

</body>
</html>

 

 

 

Grato,

 

Marcos

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.